On 7 Nov 2014, at 04:48, Kernel freak <[email protected]> wrote:
> 
> Hello friends,
> 
> I am using PDFBox to create PDF's. Thanks to some members in the mailing
> list, especially : Maruan Sahyoun, I am nicely acquainted with the
> platform, and now know how to achieve basic tasks.
> 
> While creating the PDF, I am looking for the page size to be A4(already set
> by PAGE_SIZE.A4), the page rotation in potrait mode, which is by default.

Yes, you start with portrait A4. Then you call PDPage#setRotation to rotate
the page, which also rotates the graphics.

> Problem : I would like to enter data in landscape mode. So basically, the
> text should start from left bottom end of the page which is in potrait mode
> and 90 degree tilted.

Be aware that PDF has its (0,0) coordinate at the bottom left of the page,
unlike most graphics APIs which put (0,0) in the top-right.

PDF’s graphics work in a conceptually similar way to Graphics2D, so if you
want to rotate the drawing surface (or if you want to flip the y-axis so that
(0,0) is at the top-left) then you need to apply an affine transform.

In Graphics2D this is done by calling #transform(AffineTransform) and in
PDFBox it is done by calling #concatenate2CTM(Matrix) on the current
PDPageContentStream.

You want to apply a transform which rotates the page content in the opposite
direction to which setRotation rotated it, and then translates the origin to be
at the top-left of the page.

— John

Reply via email to