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: Fwd: How to print PDF without magnifiying them ?
Date Tue, 03 May 2016 09:41:54 GMT
Am 03.05.2016 um 09:40 schrieb Pierre Antoine Guillaume:
> PDFPageable is final, would this work ?

Sorry...

>
>              PDFPageable p = new PDFPageable(pdf);
>              PDFPrintable printable = new
> PDFPrintable(pdf,Scaling.SCALE_TO_FIT);
>
>              job.setPageable(p);
>              job.setPrintable(printable);
>
> I mean, it seems to work properly and give the expexted result. But is
> there any trouble I don't know of, which I should worry about ?

I haven't heard of any troubles, but I'm really not the printing guy 
here. I found another example in the source code which uses a PDFPrintable:

     /**
      * 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


Mime
View raw message