Using *my_basefont.getFontDescriptor(BaseFont.ASCENT, my_fontsize)* I can
now calculate the top margin and bottom margin of a textfield in Acrobat by
subtracting it from the height of the field  and dividing by 2. Since
Acrobat always vertically centers the text when a box is sized in y, I can
get lly coordinate of the text inside a field.

For now I noticed that Acrobat always uses 2 units as the margin (aligned
left of course). Would be nice if I didn't have to hardcode this. I assume
there is no way to get this information by some other calculation?

I have to do all this I am doing because fields don't support spacing nor
kerning.



On Thu, Feb 17, 2011 at 2:31 AM, 1T3XT BVBA <[email protected]> wrote:

> Op 16/02/2011 19:53, Wyatt Biker schreef:
> > Is there a way to calculate the height of the font being used?
> >
> > For example, for Helvetica, 12. what would be the highest point of a
> font.
> See p68: "The font size isn't the height of any specific glyph; it's an
> indication of the vertical space used by a line of text."
>
> If you want to know the height of a String in a specific font, you have
> a plethora of methods referring to the "ascent"/"ascender" and the
> "descent"/"descender" (search for those words in the BaseFont class).
> Subtract the descent from the ascent and you have the height. See:
>
> http://www.flickr.com/photos/itextinaction/4330322144/in/set-72157623995798377/
>
>
> If you want to know the height in general, you need
> my_basefont.getFontDescriptor(BaseFont.ASCENT, my_fontsize) and
> my_basefont.getFontDescriptor(BaseFont.DESCENT, my_fontsize) where
> my_basefont is a BaseFont object and my_fontsize is your fontsize (e.g.
> 12). Again you need to subtract the descent from the ascent to get the
> height.
>
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> 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
>
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

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

Reply via email to