Form Field Dimensions

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Merger for .NET (v4)  /  Form Field Dimensions

DynamicPDF Merger for .NET (v4) Forum

 Feb 11 2008 1:57 PM
I am using MergeDocument to open an existing PDF that contains fillable fields.  I can enumerate the fields using Form.Fields - how can I retrieve the width and height of these fields?

Thanks,
Dan Schless
 Feb 11 2008 2:13 PM
Posted by a ceTe Software moderator
Hello Dan,

You can get the X, Y, Height and Width of the existing form field by using the GetX, GetY methods and the Height and Width properties of the PdfFormField class. Following is some sample code for this. Please find the attached PDF we used for this.
 
PdfDocument pdf = new PdfDocument(@"C:\Temp\test.pdf");
MergeDocument doc = new MergeDocument(pdf);
float x = pdf.Form.Fields["txt"].GetX(doc.Pages[0]);
float y = pdf.Form.Fields["txt"].GetY(doc.Pages[0]);
float width = pdf.Form.Fields["txt"].Width;
float height = pdf.Form.Fields["txt"].Height;
doc.Pages[0].Elements.Add(new Label("X: " + x.ToString() + " Y: " + y.ToString() + " Width: " + width.ToString() + " Height: " + height.ToString(), 10, 70, 200, 20));
doc.DrawToWeb();

Thanks,
ceTe Software Support Team
 Feb 11 2008 2:36 PM
Thanks for the prompt reply.  Is there also a way to retrieve the Font and FontSize in the above example?

Thanks,
Dan Schless
 Feb 11 2008 2:42 PM
Posted by a ceTe Software moderator
Hello Dan,

It is not possible to find the font and font size being used by the form field that already exists on the PDF document.

Thanks,
ceTe Software Support Team
 Feb 11 2008 3:09 PM
That is very surprising and disappointing.  Our application needs to calculate the width and height in characters of each field on existing PDFs.  Since Acrobat has no problem retrieving the Font and FontSize from a field on an existing PDF, is this something that will be addressed in a future release of DynamicPDF?  Or, are we just dead in the water?

Thanks,
Dan Schless
 Feb 11 2008 3:49 PM
Posted by a ceTe Software moderator
Hello Dan,

We do have this feature on our wish list and will likely be adding it in version 6.0 of the product. It will however not be added in v5.0 of the product which will be released soon.

Thanks,
ceTe Software Support Team

All times are US Eastern Standard time. The time now is 6:29 AM.