[ 
https://issues.apache.org/jira/browse/PDFBOX-2119?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14026787#comment-14026787
 ] 

John Hewson commented on PDFBOX-2119:
-------------------------------------

Woa there! A lot of hard work has gone into improving the printing API in 2.0 
recently and you patch just deletes it all... the orientation feature had only 
recently been added and the old (and incorrect approach) of having 
getPageFormat() set the paper size and imageable area was removed. This patch 
needs to be reverted, the new APIs are needed!

The key issue is misunderstanding what Pageable#getPageFormat() does - is _not 
responsible_ for setting the paper size, nor is it responsible for setting the 
_imageable area_, unless the user happens to have the exact size paper and 
printer that was used in the PDF file (e.g. if it's a poster they'll need a 
poster printer). Note that the imageable area is _printer-specific_, it's the 
margins which a given printer is physically able to print within, as no printer 
can print to the edge of the page. It is _not_ the size of the PDF image we 
want to print. You can see that it makes no sense for PDFBox to be trying to 
set the imageable area given that it is printer-specific! Likewise the paper 
format returned from getPageFormat() is _not_ the paper format of the original 
PDF file, it is the actual paper which the current job will print to - once 
again, PDFBox should not be choosing this.

The only thing that getPageFormat() should be doing is returning the 
paper/layout information that has been passed to it from some other source, so 
it does seem like calling printerJob.defaultPage() is not quite the right thing 
to do... some thought will have to go into what the solution is. The only 
property of the PageFormat which PDFBox should modify is the orientation, 
because that is just metadata, it doesn't actually affect physical printing it 
just tells print-preview how to display the page.

In conclusion: the existing 2.0 APIs were correct except for 
printerJob.defaultPage(), now they're broken again :(

> Possible printing bug for V2.00
> -------------------------------
>
>                 Key: PDFBOX-2119
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2119
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>         Environment: Window 7 Professional SP1, JRE 8.
>            Reporter: You Liang
>            Assignee: Andreas Lehmkühler
>              Labels: pdfbox, printer, printing
>             Fix For: 1.8.6, 2.0.0
>
>
> Printing seems to be using the window default printer paper size instead of 
> selected printService papersize.
> Etc my default Printer is an A4 Printer, and the printer that i had choosen 
> to print is a receipt printer.
> When i print to the receipt printer, it will print out a blown up version of 
> the original pdf, and when i change my default printer to the receipt 
> printer.. everything work fine.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to