I use the following code to programmatically create a TextField that is 30 lines high.
TextField tf = new TextField("fld", 0, 0, 50, 1);
tf.Font = Font.Helvetica;
tf.FontSize = 10;
float heightLine =
textField.Font.GetAscendertextField.FontSize) -
textField.Font.GetDescender(textField.FontSize) +
textField.Font.GetLineGap(textField.FontSize);
tf.Height = heightLine * 30f;
tf.MultiLine = true;
page.Elements.Add(tf);
However, after running the code, I open the PDF in Acrobat Pro and the field is 35 lines tall. What am I missing?
Thanks,
Dan Schless
Line Height Calculation
Re: Line Height Calculation
Support · Feb 7, 2008Hello Dan,
Based on your code, the height of the TextField gets set to 345 points. That may be able to accommodate 35 lines of text. That’s the likely reason you are seeing this behavior.
Thanks,
ceTe Software Support Team
Re: Line Height Calculation
Forum member · Feb 7, 2008That's true --- but my real question is why is the line height calculation so far off? Is there a better way to calculate the height of the field in this case?
Thanks,
Dan Schless
Re: Line Height Calculation
Support · Feb 8, 2008Hello Dan,
The line height calculation is returning a correct value. For the font size 10 we are getting the line height as 11.5 and total height for 30 lines is 30x11.5 = 345 which is accommodating the 30 lines.
If you can send a mail to our [^a|mailto:support@cete.com|Support Team^] we can send the output PDF and code we have used for this.
Thanks,
ceTe Software Support Team.