Tim Dylla wrote:

Call me stubborn, I'd like to have proper padding AND desired alignment.
How can I achieve this, without changing too much of my approach?

It is odd, I agree, but there's some logic behind it.

The first thing you need to know that a PdfPCell is treated as a ColumnText object.
There are two ways to add content to a ColumnText object:
- in text mode
- in composite mode
When you add objects in text mode, the alignment of the object is ignored.
You have to set the alignment at the ColumnText/PdfPCell level.
When you add objects in composite mode, the alignment of the objects is
preserved, but you may loose ColumnText/PdfPCell properties.

To solve your problem, use:
PdfPTable table = new PdfPTable(1);
table.setWidthPercentage(100f);
Phrase phrase = new Phrase(new Chunk("Hello",font));
PdfPCell cell = new PdfPCell(phrase);
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
cell.setPadding(padding);
table.addCell(cell);

HTH,
Bruno


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to