Qoppa’s Java library jPDFPrint can send PDF documents to a printer with standard print commands for text, images and shapes, but sometimes it may be necessary to send PDF pages to the printer as images rather than vector content due to the issues below:
- Occasionally, when the PDF content is very complex, some of the page content will not print on some printers. The same PDF will print correctly in other printers, and sometimes if a bit of content is modified, it will also print correctly, so this seems to be a bug related to both the printer drivers themselves and the content sent by Java.
- When there is transparent content on PDF pages, Java printing can be inefficient both in spool file size and in printing time. So customers working with lots of documents containing transparency, for instance in the pre-press or print industry, may decide to print PDF pages as images.
Here is some sample code to send PDF pages to the printer as images using jPDFPrint:
// Load the PDF document PDFPrint pdfPrint = new PDFPrint("C:\\temp\\input.pdf", null); PrintSettings ps = new PrintSettings(); ps.m_AutoRotate = true; ps.m_CenterInPage = false; ps.m_ExpandToMargins = true; ps.m_PrintAnnotations = false; ps.m_ShrinkToMargins = false; // Print the PDF document as an Image // We are using the Microsoft PDF printer as an example pdfPrint.printAsImage("Microsoft Print to PDF", ps, (PrintRequestAttributeSet) null);
The images will be set to the resolution returned by the printer. We will soon add a print settings that will allow to specify the resolution of the images sent to the printer. This was already added in our desktop application but has not been published in our public API yet.