You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Patrick Egan <pe...@gmail.com> on 2012/05/17 09:10:15 UTC

problem with PDPage 180 degree rotation

Hello List,
after I set a PDPage to 180 rotation and save the PDDocument, I can
load it in PDFReader but it displays with no rotation.
PDFDebugger tells me the rotation is 180 so it would appear that
PDFReader ignores this value.

This is also the case with PrintPDF, no 180 rotation when I print it.

In Adbobe Acrobat Reader the page is shown correctly rotated 180 degrees.

Oddly if I make the rotation 90 degrees then PDFReader does then
correctly show a 90 degree rotated page.

Ultimately I want to be able to iterate the pages and set even pages
to 180 rotation so that when the PDF is sent to a duplex printer the
the reverse sides all print at 180 to the front. So far I cannot even
get this to work with a single page.
Does anyone know what the problem may be ?

...

            PDDocument document = PDDocument.load(pdfFile);
            List pages = document.getDocumentCatalog().getAllPages();
            for (int i = 0; i < pages.size(); i++) {
                PDPage page = (PDPage) pages.get(i);
                if ((i + 1) % 2 == 0) {
                    page.setRotation(180);  /// !!! 90 works fine but
not 180 !!!!!!  - it is stored in the PDF but PDFBox does not respect
it when printing or viewing
                }

            }
            File f = new File(pdfFile);
            String newFile = f.getParent() + File.separator + "out.pdf";
            document.save(newFile);
            document.close();

...


Regards,
Patrick

Re: problem with PDPage 180 degree rotation

Posted by Andreas Lehmkuehler <an...@lehmi.de>.
Hi,

Am 17.05.2012 09:10, schrieb Patrick Egan:
> Hello List,
> after I set a PDPage to 180 rotation and save the PDDocument, I can
> load it in PDFReader but it displays with no rotation.
> PDFDebugger tells me the rotation is 180 so it would appear that
> PDFReader ignores this value.
>
> This is also the case with PrintPDF, no 180 rotation when I print it.
>
> In Adbobe Acrobat Reader the page is shown correctly rotated 180 degrees.
>
> Oddly if I make the rotation 90 degrees then PDFReader does then
> correctly show a 90 degree rotated page.
>
> Ultimately I want to be able to iterate the pages and set even pages
> to 180 rotation so that when the PDF is sent to a duplex printer the
> the reverse sides all print at 180 to the front. So far I cannot even
> get this to work with a single page.
Hmmm, your printer should do that for you. Once your are activating duplex
printing there should be an option (something like short or long side bonding) 
to define how to print all those back sides.

> Does anyone know what the problem may be ?
>
> ...
>
>              PDDocument document = PDDocument.load(pdfFile);
>              List pages = document.getDocumentCatalog().getAllPages();
>              for (int i = 0; i<  pages.size(); i++) {
>                  PDPage page = (PDPage) pages.get(i);
>                  if ((i + 1) % 2 == 0) {
>                      page.setRotation(180);  /// !!! 90 works fine but
> not 180 !!!!!!  - it is stored in the PDF but PDFBox does not respect
> it when printing or viewing
>                  }
>
>              }
>              File f = new File(pdfFile);
>              String newFile = f.getParent() + File.separator + "out.pdf";
>              document.save(newFile);
>              document.close();
>
> ...
>
>
> Regards,
> Patrick
>

BR
Andreas Lehmkühler