I saw that, but then I lose the auto orientation that is part of PDFPageable. 
The issue is I don't know what the printer will support paper size wise. I need 
to ensure that the PDF prints out correctly, so I always use Shrink to Fit. It 
may not need it, but if it does, it will be handled. I can't code the paper 
size as I don't know what it will be based on the printer selected by the end 
user. The user selects a PDF document and a printer and the system puts 
overlays on the PDF and then prints it to the selected printer.

Jon Ominsky 
Consultant Software Engineer, Life Sciences 
OpenText | Enterprise Content Division
Mobile +1 610.322.0558
[email protected] 


-----Original Message-----
From: Tilman Hausherr [mailto:[email protected]] 
Sent: Thursday, May 04, 2017 3:14 PM
To: [email protected]
Subject: [EXTERNAL] - Re: Issue printing with shrink to fit

Could this help? This is example code from Printing.java:



     /**
      * Prints using a custom page size and custom margins.
      */
     private static void printWithPaper(PDDocument document)
             throws IOException, PrinterException
     {
         PrinterJob job = PrinterJob.getPrinterJob();
         job.setPageable(new PDFPageable(document));

         // define custom paper
         Paper paper = new Paper();
         paper.setSize(306, 396); // 1/72 inch
         paper.setImageableArea(0, 0, paper.getWidth(), paper.getHeight()); // 
no margins

         // custom page format
         PageFormat pageFormat = new PageFormat();
         pageFormat.setPaper(paper);

         // override the page format
         Book book = new Book();
         // append all pages
         book.append(new PDFPrintable(document), pageFormat, 
document.getNumberOfPages());
         job.setPageable(book);

         job.print();
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to