After trying as many possibilities as I can without successful result, here is my question regarding with iTextsharp component.
I have a requirement on creating a ticket for which I decided to use the iTextSharp Library.
I have used this library on java & .net projects with fixed length documents without problems but in this case document is variable length. The document is created perfectly and accordingly with the spec. After the PDF is created I use System.Diagnostics.Process with the verb “PrintTo” for send it to the printer. Due to the variable length nature of the ticket it is not adequate to set a fixed paper length on the printer, so I use the following line to instruct the printer to take the document size (accordingly with Manning iText in Action 2nd Edition, page 140) but it seem not to function properly.
writer.AddViewerPreference(PdfName.PICKTRAYBYPDFSIZE, new PdfBoolean(true));
Any ideas on how could I send the document to printer instructing the printer to adjust the paper size to the document size?
Thanks in advance,
By using GhostScript (GHS) and mswinpr2as printing device we were able to print to practically any printer recognized for the Operative System (Windows).
To stablish the paper size it is necesary to set the following arguments when invoking GHS command line utility (gswin32c):
dFIXEDMEDIA
dDEVICEWIDTHPOINTS = value
dDEVICEHEIGHTPOINTS = value
sOutputFile = "%printer%PRINTER_NAME"
Related
I'm trying to generate a PDF that can be viewed interactively in Adobe Reader, but also, upon printing, selects different paper trays based on the page. (Some pages are supposed to use stationery, whereas other must not.)
PDF itself apparently doesn't support this form of metadata by design (as discussed e.g. here), but apparently, JDF is an appropriate format, and can be embedded as XML in the PDF.
What's less clear to me is if Adobe Reader does anything useful with that metadata: if a PDF with embedded JDF information is printed, does it parse the JDF and choose paper trays? Can I use PDF portfolios for this purpose instead?
My goal is to both let the user view the PDF in Adobe Reader interactively, and, upon printing, automatically selecting different paper trays.
(The far less convenient alternative would be to write a custom app to do the printing.)
You are right, PDF describes the artwork while the JDF describes the metadata about print. However, JDF is targeted to industrial printing systems rather than for desktop printers. As far as I know does Adobe Acrobat Reader not support this kind of feature based on a JDF.
In order to control the different paper trays of your printer, you may setup your printer several times - one for each tray and switch the flag "default printer" in the background programmatically.
Another idea could be to use the Acrobat Reader only for viewing purposes and using the command line for printing.
There are concepts of how to put metadata into the PDF directly (see: https://confluence.cip4.org/display/PUB/PDF+Intent), but it could take a while until this specification is gonna to be implemented.
I read that the XPS printer in Windows 8 produces OpenXPS (.oxps) files whereas its counterpart in earlier Windows versions produce XPS (.xps) files. So printing XPS files under Windows 8 implies a compatibility issue. Fair enough. But, what type of file does the CreateXpsDocumentWriter method create?
Does it use the XPS printer? If yes, how can you detect which XPS/OXPS setting the printer has? Or is it possible to choose XPS/OXPS via an API?
If the extension is oxps, chances are that you got an openxps. try renaming it to .zip. If it's openXPS, you will be able to view the contained parts.
According to the remarks in the XpsDocument class description, you will get XPS, not OpenXPS
("For more information about XPS see the XML Paper Specification (XPS) available for download at http://go.microsoft.com/fwlink/?LinkID=65761.")
I'm using iTextSharp to generate PDF documents in my asp.net application. That works great. The only issue I have is when I generate a PDF document with size of a legal paper and print it, the printer use the default paper which is letter size. I have to change the printing options manually in order to print it in legal paper. Is there a way I can specify in which paper size I want the document to print programmatically so that I won't have to do it manually?
I'm using this line of code to specify the page size in iTextSharp:
Document doc = new Document(PageSize.LEGAL.Rotate());
You cannot control the client printer. That would be a huge security problem in the PDF format. It is up to that computer's settings.
Ok, I found the answer in another post: Propagate the orientation setup at iTextSharp.text.Document creation to the Print dialog.
The key is to set the viewer preference Choose paper source by PDF page size to true.
writer.AddViewerPreference(PdfName.PICKTRAYBYPDFSIZE, PdfBoolean.PDFTRUE);
My project is a Tamil to Braille translation system. I want to make an print-out of a Braille document, and used the normal printer code in c# (printer dialog), but my embosser printer is just printing garbage instead of my document.
Is there any special way to print with an embosser printer from C#? Can you help me to fix this problem? My printer is index braille Basic D version 3, and my document is a braille document.
You need to send raw data to the printer. I have done this with version 4 printer, but I think it will work with version 3 too.
Check this class from Microsoft http://support.microsoft.com/kb/322091
I've been programming an application that deals with a POS printer. The printer is BIXOLON branded, and I haven't found any SDKs for using this type of printers as well as no example on how to deal with it.
Since I'm new to this type of printer, I don't know how should I design my report as well as which report engine should I use.
Any advice will be helpful.
I have worked on POS printers before to issue receipts etc.
What I did is to read in a template from a rtf file, set some variables that is to be replaced.
For example for the receipt I want to have the name of the person, so in the rtf file template, I would put something like <NAME>. When I read in the content of the rtf file, i just do a string.replace to replace <NAME> with the actual text in my program. Once I have replaced all the variables, using the class found in this link.
http://msdn.microsoft.com/en-us/library/ms996492.aspx#wnf_richtextbox_topic06 , I have a well formatted rtf and ready to be printed.
Printing wise works just like other printer. This means that as long as your coding targeted the correct printer and using the correct setup, it should be printed correctly. The only difference is that printing on a office printer would give u a A4 size, whereas printing on a POS printer will give you the size allowed by the POS printer. Just remember to format your rtf well.
Most report engines (I'm thinking of Reporting Services in particular) won't need this level of programming to print reports. You will get that functionality out of the box as long as the printer drivers are installed on the machine you wish to print reports from.
It was so simple, I used crystal report to design my report and then easily show.