« Return to Thread: How to calculate text-height when using PDFContentByte?

Re: How to calculate text-height when using PDFContentByte?

by pocketom () :: Rate this Message:

Reply to Author | View in Thread

Hello Paulo,

thank you for your reply. I would be interested in getting the maximum height, e.g. when thinking in uppercase letters only, or like when drawing a box around a word or sentence that tangents at least one character at bottom and the top side without cutting through another char. Hope that makes it more clear...?


<EDIT>
I've managed it:


[code]
public float getTextheight(BaseFont baseFont, float fontSize)
{
                float ascend = basefont.getAscentPoint(text, fontSize);
                float descend = basefont.getDescentPoint(text, fontSize);
                return ascend - descend;
}

[code]

</EDIT>

 « Return to Thread: How to calculate text-height when using PDFContentByte?