pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Ominsky <jomin...@opentext.com>
Subject Re: Issue printing with shrink to fit
Date Thu, 04 May 2017 19:17:21 GMT
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
jominsky@opentext.com 


-----Original Message-----
From: Tilman Hausherr [mailto:THausherr@t-online.de] 
Sent: Thursday, May 04, 2017 3:14 PM
To: users@pdfbox.apache.org
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: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


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


Mime
View raw message