So I\'m dealing with a situation where I have a Phrase added to a ColumnText object.
>
Please take a look at the ColumnTextAscender example:
In both cases, I have drawn a red rectangle:
rect.setBorder(Rectangle.BOX);
rect.setBorderWidth(0.5f);
rect.setBorderColor(BaseColor.RED);
PdfContentByte cb = writer.getDirectContent();
cb.rectangle(rect);
To the left, you see the text added the way you do. In this case, iText will add extra space commonly known as the leading. To the right, you see the text added the way you want to add it. In this case, we have told the ColumnText
that it needs to use the Ascender value of the font:
Phrase p = new Phrase("This text is added at the top of the column.");
ColumnText ct = new ColumnText(cb);
ct.setSimpleColumn(rect);
ct.setUseAscender(true);
ct.addText(p);
ct.go();
Now the top of the text touches the border of the rectangle.