I try to print a PDF using the following code
But if my PDF is LANDSCAPE and the printer instead as PORTRAIT as default, PORTRAIT wins and so the report is not well printed.
Checking the code (based on 1.5.0 and also from lateast trunk) for class PDPageable... probably I found the issue.. and I believe that the implementation is not right (at least from my point of view).
Get a look to the getPageFormat method.
As first it get the page format from the job (PrinterJob)
PageFormat format = job.defaultPage();
after it get the (optional) print service from the job (Printer Job)
PrintService service = job.getPrintService(); // can be null
If the printer service is not null and it have LANDSCAPE as orientation.. it force LANDSCAPE as orientation in the page format otherwise it force it as PORTRAIT
But... in my mind, it should get the orientation from the PDF Page.. and not from the printer job / print service.
I can print documents with different orientation on the same printer and also I can have in the same document pages with different orientation.
Of couse I can make same mistake and read the code in the wrong way... (I found this project yesterday....)
Maybe the "findRotation" method on the PDPage should be invoked and "checked".. or something else....
It this a bug on PDFBox ?