So I'm dealing with a situation where I have a Phrase added to a ColumnText object.
The title in black is where iText is placing the text of the Phrase within the ColumnText. The title in pink is the desired placement.
private void addText(PdfContentByte contentByte, PdfReader threePagesReader, Project project, CoverTemplate coverTemplate)
throws DocumentException {
ColumnText columnText = new ColumnText(contentByte);
// This only affects the space between Phrases, not the space between the top of the
//ColumnText and the first Phrase
int extraParagraphSpace = 12;
columnText.setExtraParagraphSpace(extraParagraphSpace);
Phrase mainTitle = new Phrase(project.getTitle(),buildCoverFont(coverTemplate.getFontSizeLine1()));
columnText.addText(mainTitle);
... <other code that is not pertinent to this question>
//these values are calculated from values that will place this columnText onto the PDF
//template
columnText.setSimpleColumn(llx, lly, urx, ury);
columnText.go();
private Font buildCoverFont(float fontSize) {
Font font = FontFactory.getFont(FONT_ARIAL, BaseFont.WINANSI, BaseFont.EMBEDDED, fontSize, Font.NORMAL, CMYK_BLACK);
BaseFont baseFont = font.getBaseFont();
if (baseFont != null) {
baseFont.setSubset(false); // fully embedded as per requirements
}
return font;
}
Is there anything I can do to tell iText not to put any space between the top of the highest glyphs (D and Z in this case) and the top of the ColumnText box?
I tried looking at the BaseFont.getAscension() to see if there was any value available, but it ended up 0 anyway.