pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: Sending the PDF document silently to a pre-defined printer
Date Fri, 08 Jul 2016 19:48:14 GMT
I'm looking at the source code of PrintPDF, it has a "secret" option 
"-printerName". Here's the code that is used:

             PrinterJob printJob = PrinterJob.getPrinterJob();
             printJob.setJobName(new File(pdfFile).getName());

             if (printerName != null)
             {
                 PrintService[] printService = 
PrinterJob.lookupPrintServices();
                 boolean printerFound = false;
                 for (int i = 0; !printerFound && i < 
printService.length; i++)
                 {
                     if (printService[i].getName().contains(printerName))
                     {
                         printJob.setPrintService(printService[i]);
                         printerFound = true;
                     }
                 }
             }
             printJob.setPageable(new PDFPageable(document));

             if (silentPrint || printJob.printDialog())
             {
                 printJob.print();
             }

Note that this is for 2.0.2.

Tilman

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message