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) of inline images, and many contain transparency. Some are as small as 1 pixel by 1 pixel.

A zoomed in area in the document, where each blue square represents an image.

Our Java PDF rendering engine has been optimized over the years and is able to display these kind of document quite efficiently.

But when it comes to printing, we are unfortunately running into a Java-related issue:

As soon as there is transparency, Java goes into a weird behavior where it keeps calling back the printing code with each transparent section. And because there are many images with transparency in your document, that slows down the process a lot.

There are many postings about this issue but unfortunately this issue has not yet been fixed by Oracle and no workaround is available.

If this is a typical document in your workflow, you can look at optimizing the document on the PDF creation. If you do not have control over the PDF creation, you can look at converting the pages to images and sending the images to the printer directly. In jPDFPrint v2018R1 and over, there is a new public method to first convert each page to an image and then sending the image to the printer:

PDFPrint.printAsImage(String printerName, PrintSettings printSettings, PrintRequestAttributeSet printAttrSet)