You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Andreas Lehmkühler <an...@lehmi.de> on 2010/04/07 13:19:03 UTC
Re: Portrait vs landscape
Hi,
sorry for answering that late
Maruan Sahyoun schrieb:
> Hi,
>
> you have to set the media box e.g.
>
>
> document = new PDDocument();
> PDPage page = new PDPage();
> PDRectangle pageFormat = new PDRectangle(843f, 596f);
> page.setMediaBox(pageFormat);
> document.addPage(page);
That is one possible solution, but not the preferred one. AFAIK most(all?)
pdf tools are using a portrait pageformat and a transformation matrix
to rotate every content of a page.
Our test arena contains e.g. the pdf "rotation.pdf". In consists of two pages,
one with a portrait orientation and the other with a landscape orientation.
This is the definition for the pages, both have the same pageformat
Page 1:
=======
7 0 obj
<<
/CropBox [0 0 612 792]
/Parent 3 0 R
/Contents 10 0 R
/Rotate 0
/MediaBox [0 0 612 792]
/Resources 11 0 R
/Type /Page
>>
endobj
Page 2:
=======
8 0 obj
<<
/CropBox [0 0 612 792]
/Parent 3 0 R
/Contents 12 0 R
/Rotate 90
/MediaBox [0 0 612 792]
/Resources 13 0 R
/Type /Page
>>
endobj
Both pages are using a transformation matrix for the text.
Page 1:
======
uses 12 0 0 12 90 708.96 Tm
It describes a scaling with a factor of 12 (and a x-y-translation of 90 708.96)
Page 2:
======
uses 0 12 -12 0 101.04 72 Tm
It describes a combination of a scaling and a shearing (and a x-y-translation of 101.04 72)
The rotate value is only used to automatically rotate the view within the acrobat reader.
[1] demonstrates how to set a text matrix using a PDPageContentStream [2]. To rotate other objects
than text, the current transformation matrix (pdf operator = cm) has to be used. There is no direct support within
the PDPageContentStream but the usage is similar to the text transformation matrix.
Be aware that a new text matrix (tm) replaces an old one, but a new current matrix (cm) will be concatenated
with the existing one.
>> b) Is there a way to "search" the archives? I can browse but cannot find a
>> way to do a search.
Have a look at [3], it lists several services which can be used to search the mailing lists.
BR
Andreas lehmkühler
[1] http://svn.apache.org/repos/asf/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/examples/pdmodel/UsingTextMatrix.java
[2] http://svn.apache.org/repos/asf/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/edit/PDPageContentStream.java
[3] http://pdfbox.apache.org/mailing-list.html