I am trying to scale down a phrase until it will fit in a given rectangle. I'm
using a ColumnText, and calling go(true), then testing for HasMoreText. But
the status returned by go() keeps being 2 even when all the text fits easily
into the rectangle.
What am I doing wrong?
float fontSize = pageMetrics.getFontSizeMax();
Phrase labelPhrase = GeneratePhrase(fontSize);
// Now we scale the text down until either it fits or we run up against
the specified minimum font size
Rectangle textBox = getSpaceForLabelText();
ColumnText col = new ColumnText(directContent);
col.setSimpleColumn(textBox);
col.addElement(labelPhrase);
int textPrintingStatus = ColumnText.START_COLUMN;
try {
textPrintingStatus = col.go(true);
while(ColumnText.hasMoreText(textPrintingStatus) && fontSize >
pageMetrics.getFontSizeMin() ) {
fontSize--;
labelPhrase = GeneratePhrase(fontSize);
col.clearChunks();
col.addElement(labelPhrase);
textPrintingStatus = col.go(true);
}
result.printedFontSize = fontSize; // record the font size
actually used
} finally {
}
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php