davidahines
davidahines

Reputation: 4094

In Itext, how do I flip the contents of a cell upside down?

I have a pdfptable with some pdfpcells and this sheet is printed off and brought around with each part. When the part is on the rack, the sheets are upside down. How can I write some text into a pdfpcell and then rotate it 180 degrees?

Upvotes: 1

Views: 689

Answers (2)

Damienknight
Damienknight

Reputation: 1896

pdfpcells details here: http://api.itextpdf.com/itext/com/itextpdf/text/Image.html

[Edit] Ignore below method, use setRotation as Dah discovered below. Thanks for the upvote Dah, I didnt deserve it :)

You will have to create an image, draw your text to the image, translate the image to -y, or rotate the image.

Then write the image to url, and then pass that image url into the constructor for an 'com.itextpdf.text.Image'.

For drawing text in an image: Java - Draw text in the center of an image

Draw the image upside down:

g2d.translate(0, 2 * imageHeight + gap);
g2d.scale(1, -1);

OR

Rotate the image: Java: Rotating Images

Then:

Write an image to a file: http://docs.oracle.com/javase/tutorial/2d/images/saveimage.html

Upvotes: 1

davidahines
davidahines

Reputation: 4094

Apprently I missed the Oh-so-obvious PdfPCell.setRotation();

Upvotes: 0

Related Questions