Sample Java Program to Print to a given printer

This is a sample Java program to check Java printer connections on your machine. It will print a page with a yellow image on it to the first print service found. package test;   import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.awt.print.PageFormat; import java.awt.print.Printable; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; import javax.print.PrintService;   public class […]

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