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); // Create attribute set to print to a file File outputFile = new File ("output.pcl"); PrintRequestAttributeSet attrSet = new HashPrintRequestAttributeSet (new Destination (outputFile.toURI())); // Send the PDF to the printer pdfPrint.print ("printer name", null, attrSet); |
To use Qoppa’s library jPDFProcess instead of jPDFPrint, replace PDFPrint with PDFDocument in the code above.