Skip to main content
Skip table of contents

How to rotate a paragraph?

Why can't I rotate anything bigger than a single line?

I have a web site where the users upload photos and create photobooks. Also, they can add text at absolute positions, rotations, and alignments. The text can have new lines.

I've been using the iText Library to automatize the creation of the Photobooks Hight Quality PDFs that are printed latter on.

Adding the user uploaded images to the PDFs was really simple, the problem comes when I try to add the text.

In theory what I would need to do, is to define a paragraph of some defined width and height, set the users text, font, font style, alignment (center, left, right, justify), and finaly set the rotation.

For what I've read about Itext, I could create a Paragraph, set the user properties, and use a ColumnText object to set the absolute position, width and height. However it's not possible to set the rotation of anything bigger than single line.

I cant use table cells either, because the rotation method only allow degrees that are multiples of 90.

Is there a way to add a paragraph with some rotation (say 20 degrees) without having to add the text line by line using the ColumnText.showTextAligned() method and all math that involves?

Posted on StackOverflow on Mar 14, 2013 by BernalCarlos

With iText 7 you need only one step to solve your problem:


The result looks like:

Rotate paragraph

Rotate paragraph

Click How to rotate a paragraph? if you want to see how to answer this question in iText 5.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.