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
Form Field Dimensions
Re: Form Field Dimensions
Support · Feb 11, 2008Hello 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
Re: Form Field Dimensions
Forum member · Feb 11, 2008Thanks for the prompt reply. Is there also a way to retrieve the Font and FontSize in the above example?
Thanks,
Dan Schless
Re: Form Field Dimensions
Support · Feb 11, 2008Hello 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
Re: Form Field Dimensions
Forum member · Feb 11, 2008That 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
Re: Form Field Dimensions
Support · Feb 11, 2008Hello 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