You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Andreas Lehmkühler (JIRA)" <ji...@apache.org> on 2013/03/03 15:55:13 UTC

[jira] [Resolved] (PDFBOX-985) PDF Printing Orientation

     [ https://issues.apache.org/jira/browse/PDFBOX-985?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Lehmkühler resolved PDFBOX-985.
---------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.8.0
         Assignee: Andreas Lehmkühler

This should work after resolving PDFBOX-1138.

Set to resolved
                
> PDF Printing Orientation
> ------------------------
>
>                 Key: PDFBOX-985
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-985
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 1.5.0
>            Reporter: Roberto Mazzola
>            Assignee: Andreas Lehmkühler
>              Labels: print
>             Fix For: 1.8.0
>
>
> I try to print a PDF using the following code
> {code}
> // aDevice is the printer device Name
> // aData is a byte array of my PDF (stored on a DB)
> ....
> 			vPrintService = this.getPrintService(aDevice);
> 			vPrinterJob = java.awt.print.PrinterJob.getPrinterJob();
> 			vPrinterJob.setPrintService(vPrintService);
> 			vPDDocument = this.getPDDocument(aData);
> 			vPDDocument.silentPrint(vPrinterJob);
> --
> {code}
> {code: Suppors methods}         
> public PrintService getPrintService(String aDevice) throws Exception
> {
> 	javax.print.PrintService[] vPrintServices = java.awt.print.PrinterJob.lookupPrintServices();
>     boolean printerFound = false;
>     for(int i = 0; i < vPrintServices.length; i++)
>     {
>     	if(vPrintServices[i].getName().trim().equals(aDevice.trim()))
>         	return vPrintServices[i];
>     }
> 	 return null;
> }
> public PDDocument getPDDocument(GenericBean aData) throws Exception
> {
>    byte[] vPageData  =  (byte[])aData.getValueAtKey("Byte");
>    return PDDocument.load( new ByteArrayInputStream(vPageData) );
> }
> {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 ?
> thanks
> Roberto

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira