views:

444

answers:

1

I am using itext to write pdf, but in some cases, I need to sign the pdf with SetVisibleSignature function, and we know, with this function, we need to designate the rectangle that we will write the content into it, But it's hard for me to calculate how large the string will occupy, then I can set the rectangle before set a signature on the pdf,

anyone have good idea ?

+1  A: 

You can use BaseFont.getWidthPoint(String text, float fontSize) to get the width of the string in pt.

Or put the string in a Chunk and do chunk.getWidthPoint()

Jan Soltis