You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Brandon Berry <ra...@gmail.com> on 2009/08/13 19:44:45 UTC

Rotate Text

How do I write rotated text to a page?

I have a PDF document that was created externally with a landscape
orientation. It appears fine when viewed with text going left to right. But
PDFBox sees it as having a portrait orientation and rotated 90 degrees.

So when I add text to the page, it gets written perpendicular to the
existing text, going from bottom to top with respect to how the document is
viewed. I'm thinking I either need to rotate the text being added or
convince PDFBox it's landscape with no rotation.

Looking through the mailing list archives, I think I found some discussions
that might be related but found no solutions. I had previously been thinking
I would need to use a transformation matrix and that subject did come up in
those discussions. But I can't find anyway to apply any transformations from
the methods available to me. Is that the correct approach?

I am using the released version 0.7.3 DLLs for a .NET project.

Thanks for your help.

Re: Rotate Text

Posted by Andreas Lehmkühler <an...@lehmi.de>.
Hi Brandon,

Brandon Berry schrieb:
> How do I write rotated text to a page?
> 
> I have a PDF document that was created externally with a landscape
> orientation. It appears fine when viewed with text going left to right. But
> PDFBox sees it as having a portrait orientation and rotated 90 degrees.
> 
> So when I add text to the page, it gets written perpendicular to the
> existing text, going from bottom to top with respect to how the document is
> viewed. I'm thinking I either need to rotate the text being added or
> convince PDFBox it's landscape with no rotation.
> 
> Looking through the mailing list archives, I think I found some discussions
> that might be related but found no solutions. I had previously been thinking
> I would need to use a transformation matrix and that subject did come up in
> those discussions. But I can't find anyway to apply any transformations from
> the methods available to me. Is that the correct approach?
You are right. You have to use an additional textmatrix to rotate the
text. But I'm afraid there is yet no easy way to add it the
contentstream. You have to add all pdf commands on your own using the
appaendRawCommand method in PDPageContentStream.
I've created a new issue on jira [1] to keep that in mind. I'll need
that missing feature sooner or later too.

BR
Andreas Lehmkühler

[1] https://issues.apache.org/jira/browse/PDFBOX-505