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 […]
Category: jPDFPrint: Print PDFs
Developer library to print PDF documents in Java.
Missing / blank page content when printing from Java to specific printer drivers
Q: Sometimes, when sending a PDF document to the printer using Qoppa jPDFPrint library, some pages are printing completely blank or partially blank. Our printer is HP Universal Printing PCL 6 (v6.5.0). How can we resolve this problem? A: We’ve seen a similar issue happen on rare occasions. We do send all of the content […]
Printing images in strips and Java Bug when printing rotated images
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 […]
How can you set Java PrinterJob to Print to a File instead of a Printer
When you need to test printing processes in Java, it may be easier to print to files rather than printing to a printer. In the sample Java program below, we are finding the Microsoft XPS Document Writer, but you could find any other printer drivers installed on your machine, such as a Postscript driver or […]
How to get printer status reason (no paper, no toner) when printing documents with Java?
Q: When printing PDF documents with Java using jPDFPrint, how can we get more information on the status of printer for instead to know if the printer is turned on or off, if the printer has paper, is out of toner, etc… A: When printing a PDF document using Qoppa’s jPDFPrint API, all the print […]
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); […]
Error handling versus exception thrown when rendering PDF pages in jPDFImages and jPDFPrint
When rendering pages in a PDF document, jPDFPrint and jPDFImages may run into errors. In this case, the libraries will render the page with a red X drawn across the page, together with a message explaining what failed, such as “Error Handling Page: Missing Font”. Customers can choose to throw an exception instead, if they […]
Invalid colors for CMYK images when cmykProfile.jar missing in classpath
Update: As of version v2019R1, cmykProfile.jar is now packaged inside Qoppa’s library jars and no longer requires to be added to the 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, […]
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 an “Error Rendering Page” displayed in red on a page. This error happens when there is an issue with a font within the PDF document. There are 2 possible […]
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 […]
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 […]
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 […]
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 […]
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. […]
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) { // […]
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) […]
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 […]
Print Settings (margins, rotation, centering,..) when printing PDF in Java
Q: When we print PDF documents using Qoppa’s library jPDFPrint or components (jPDFViewer, jPDFNotes or jPDFEditor), how can I adjust the print margins? I want the printed page to be exactly the same as when printing with Adobe® Reader®’s. A: We spend a lot of time making sure that our printouts match Adobe Reader / […]
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 […]
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.
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 […]
Resolved: Random Windows Java javax.print.PrintException: Printer is not accepting job
This entry applies to all our libraries and components that can print PDF documents: jPDFPrint, jPDFProcess, jPDFViewer, jPDFNotes, jPDFEditor. Q: We have an issue when sending PDF documents to the printer using jPDFrint on a Windows Server. Every now then we do get either one of the following error message: “Printer is not accepting job”. […]
Print a PDF loaded in memory (byte array) without saving it as a file
Q: Is it possible to send a PDF in memory to a printer using jPDFPrint without saving it first? If so how? A: Yes it is possible. There are different constructors in the PDFPrint class to load documents, one of them takes a Java InputStream to read the PDF content from. If you have the […]
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 […]
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 […]
Code Sample: Print PDF document with cover page in Java
A java program that uses jPDFPrint to print a cover page before printing the rest of the document using Qoppa’s library jPDFPrint.
Code Sample: Print multiple PDF files in a single print job in Java
A Java class that can print multiple PDF documents as a single print job. The class takes a list of PDF documents, creates a PrinterJob and then uses jPDFPrint to print the documents. This sample basically shows how to merge multiple documents as you are sending them to the printer so they all show under […]
Code Sample: Print a PDF document with DocPrintJob and PrintJobListener
A Java program that uses the javax.print.DocPrintJob related classes to print a PDF document using Qoppa’s library jPDFPrint. The class registers itself as a javax.print.event.PrintJobListener to receive events related to the progress of the print job.
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 […]
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; […]