pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gregor Kova─Ź <kov...@gmail.com>
Subject PDF Printing: multiple copies
Date Thu, 07 May 2015 23:04:55 GMT
Hi!

I'm using PDFBox 1.8.9 and using this method to print a PDF file:

private static void printWithPDFBox(File pdfFile, int copies) {
    PDDocument document = null;

    try {
        document = PDDocument.load(pdfFile);

        PrintService printService =
PrintServiceLookup.lookupDefaultPrintService();
        PrinterJob printJob = PrinterJob.getPrinterJob();
        printJob.setJobName(pdfFile.getName());
        printJob.setPrintService(printService);
        printJob.setCopies(copies);

        HashPrintRequestAttributeSet printRequestAttributeSet = new
HashPrintRequestAttributeSet();
        printRequestAttributeSet.add(new Copies(copies));
        printRequestAttributeSet.add(SheetCollate.COLLATED);
        printJob.setPageable(new PDPageable(document, printJob));
        printJob.print(printRequestAttributeSet);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (document != null) {
            try {
                document.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}


I have a test file with one page and when I call this method with copies
greater than 1 I only get one page printed out.

Am I doing something wrong?

Best regards,
    Kovi

-- 
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
|  In A World Without Fences Who Needs Gates?  |
|              Experience Linux.               |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message