Java has a bug when printing a rotated image (such as a deskewed scan for instance), it adds weird artifacts at the border of the images that look like black doted lines. This does not happen on rendering, only on printing. We’ve reported it to Java and it was recognized as a bug.

This has some very unfortunate consequences when printing PDF pages containing rotated images in jPDFPrint. The problem is compounded by the fact that we split an image in multiple strips order when drawing it in order to handle very large images printed at very high definition.

The result can look like this (here shown with strips of 4MB)

This is the bottom of a rotated scanned page printed with jPDFPrint. This code is using 4MB strips and you can see many artifacts around each strip.

If you are seeing this problem, while waiting for a Java fix, we’ve added a setting in version v2017R1.13 that allows to minimize the number of strips used when printing an image. This is measured in memory (in MB) contained in each strips. jPDFPrint will use a default of 8MB for each strip but you can increase the amount to lower the number of strips. If you set it too high, your application might run out of memory. Here is a code sample of this setting is changed to 24Mb.

// Load the PDF document
PDFPrint pdfPrint = new PDFPrint("C:\\support\\orig.pdf", null);
 
// we're sending images as strips to the printer
// in order to handle very large images printed at very high definition
// the default strip size when printing images is 8Mb 
// You can overwrite this size to change it to 24MB strips for ex
PDFRenderHints.setImagePaintingMemoryMB(24);
 
// Create attribute set to print to a file
File outputFile = new File ("C:\\support\\output2.xps");
PrintRequestAttributeSet attrSet = new HashPrintRequestAttributeSet (new Destination (outputFile.toURI()));
 
// Send the PDF to the printer
pdfPrint.print ("Microsoft XPS Document Writer", null, attrSet);
This is the same rotated scanned page printed with 24Mb strips. There is only one big strip in this case and artifacts are only visible on the outside.