Print PDF to Printer File Format (PCL, PRL, or PS) using Java

Here is a simple Java program showing how to use jPDFPrint to print a PDF document to a printer driver file format. In this example, the printer outputs a pcl file (Printer Command Language) but printers might output a prn file or postcript file. // Load the PDF document PDFPrint pdfPrint = new PDFPrint("input.pdf", null); […]

Read More

Invalid colors for CMYK images when cmykProfile.jar missing in classpath

When rendering or optimizing images with a CMYK color space (DeviceCMYK), Qoppa’s PDF libraries and components need the cmykProfile.jar to be present in the classpath. If you forget to include this jar, you will get images with “weird” colors. Faces for instance will show with more intense, bright saturated colors (such as red and blue) […]

Read More

How to Resolve Error Rendering Page: Missing Font

When rendering a PDF document in the following Qoppa’s PDF library products: jPDFImages, jPDFPrint, jPDFProcess, jPDFViewer, jPDFNotes or jPDFEditor, you might encounter a blank page with the following error displayed on a page. This happens because the PDF document is calling for a font, ‘F0’ in this case, that is not embedded in the document […]

Read More

On using Java RenderingHints to smooth jagged edges on rotated images

Q: There seems to be some pixelation or resolution issue when rendering specific images in a PDF brochure. Is there anything that can be done to render these images more smoothly? A: Qoppa’s PDF libraries and components uses our own interpolation algorithm that works much better than the built-in Java algorithm well both when up-sampling […]

Read More

How to print PDF pages with a 180 degrees orientation with jPDFPrint

This Java sample shows how to use jPDFPrint printable to implements your own Printable interface which can be useful when you need a finer control over the printing of PDF pages. In this sample, we’re changing the rotation of the page printouts by -180 degrees. package jPDFPrintSamples;   import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.print.PageFormat; import […]

Read More

Invalid CMAP name when rendering or printing a PDF page

Q: When opening a PDF file, I get the following error: A: You are missing cmaps.jar in your classpath which contains CMaps, used to read and display character encodings used with CJK (Chinese, Japanese, Korean) content. Download cmaps.jar   This error can happen when rendering PDF documents in Qoppa’s PDF components (jPDFViewer, jPDFNotes, jPDFEditor) or […]

Read More

Staple and Duplex options when printing PDF in Java

Q: Is it possible to specify staple & duplex options on a per-document basis with jPDFPrint? A: Yes, it is:  Java supports setting print job attributes for each print job, this is done through PrintRequestAttribute objects. jPDFPrint supports passing these attributes through. The attributes that you want to use are: javax.print.attribute.Finishings.STAPLEjavax.print.attribute.Finishings.STAPLE and javax.print.attribute.Sides.DUPLEXjavax.print.attribute.Sides.DUPLEX Here is a sample […]

Read More

Slow when printing a PDF page that has a watermark

Q: When I print a page with no watermark, it prints quite fast, less than 2 seconds, as expected. But when I add a “Draft” watermark to the same page and send it to the printer, it prints much slower and can take up to 20 or 30 seconds for the same page to print. […]

Read More

Display the List of Printers visible to Java

This is a small utility class that lists the printers as seen by Java. This class is useful because in some cases, Java shows a different name for a printer than the one reported by the operating system. import java.awt.print.PrinterJob; import javax.print.PrintService; public class ListPrinters { public static void main (String [] args) { // […]

Read More

Very slow to print a PDF document with transparency in Java

Q:  We are experiencing some performance issue when printing a specific PDF with jPDFPrint. It takes a very long time to print, about 24 minutes on our Windows machine, when printing with Java 1.7. A: We looked at the document you sent. Your document was created with GPL Ghostscript and contains hundreds (if not thousands) […]

Read More

Selecting both tray and paper size when printing in Java

When printing in Java, it is only possible to specify one media attribute: either paper or tray. In theory, if you choose the tray then Java knows what paper size to use and the other way around. But in practice, this does not always work and there may be situations where you need to specify […]

Read More

Print PDF documents to a specific printer on an IBM iSeries AS400

Q: On an IBM iSeries (AS400), how can I get jPDFPrint to use a certain printer to print PDF documents? When I query for printers with: PrinterJob().lookupPrintServicesPrinterJob().lookupPrintServices I get an empty array. So how do I specify a printer for jPDFPrint to use? A: There is a good technical note about using the Java Print Services APIs on […]

Read More

jPDFPrint Java API

Q: Where can I find jPDFPrint javadoc API? A: You can find the API specification for the latest version of our library jPDFPrint on our website at this link. jPDFPrint is a java library to print PDF documents in Java.

Read More

Sample Code: Print a PDF document with print request attributes

A Java program that prints a PDF document using some of the print request attributes available using Qoppa’s library jPDFPrint. // Load the PDF document PDFPrint pdfPrint = new PDFPrint("input.pdf", null);   // Create attribute set to print to a file HashPrintRequestAttributeSet attrSet = new HashPrintRequestAttributeSet(); attrSet.add(PrintQuality.HIGH); attrSet.add(Chromaticity.MONOCHROME);   // Send the PDF to the printer […]

Read More

How is the PDF document sent to the printer using jPDFPrint?

Q: Does jPDFPrint convert the PDF document to images before printing or does it send the PDF document to the printer directly as a PDF? A: None of the above. jPDFPrint does NOT convert to images and does NOT send the PDF directly: jPDFPrint reads and interprets the PDF document and then sends drawing commands to […]

Read More

Code Sample: Silent print a PDF document in Java

A Java program that prints silently a PDF document to the default printer. package jPDFPrintSamples; import com.qoppa.pdfPrint.PDFPrint; public class SimplePrint { public static void main (String [] args) { try { PDFPrint pdfPrint = new PDFPrint("input.pdf", null); pdfPrint.printToDefaultPrinter(null); } catch (Throwable t) { t.printStackTrace(); } } }package jPDFPrintSamples; import com.qoppa.pdfPrint.PDFPrint; public class SimplePrint { public […]

Read More

Code Sample: Print a PDF document with a watermark in Java

A Java program that uses jPDFPrint to print a PDF document and adds a watermark on every page. We defined an interface called IWatermark that makes it easy for users to define and customize their own watermark, including text, font, color, location and orientation by simply using the well-known Graphics2D Java class. // Load PDF document PDFPrint […]

Read More

Code Sample: Print a PDF document to a given printer in Java

A Java program that prints silently a PDF document to a named printer using jPDFPrint. package jPDFPrintSamples;   import com.qoppa.pdfPrint.PDFPrint;   public class SimplePrintDefault { public static void main (String [] args) { try { PDFPrint pdfPrint = new PDFPrint("input.pdf", null); pdfPrint.print ("my printer", null); } catch (Throwable t) { t.printStackTrace(); } } }package jPDFPrintSamples; […]

Read More

Code Sample: Convert PDF to Postcript in Java

A Java program that uses jPDFPrint to convert a PDF file to Postscript. The program queries the JVM for any print services that support Postscript output. At least one such services is always available in a Sun JVM. It then prints the PDF document, using jPDFPrint, to that print service, which will ouptut a Postcript file. ocFlavor […]

Read More