I am trying to access the x and y position of form fields in a pdf created in LifeCycle Designer 7.0.
Here is the code I am using:
Dim MyPdfDocument As PdfDocument = New PdfDocument("form1.pdf")
Dim mymergedoc As MergeDocument = New MergeDocument(MyPdfDocument, MergeOptions.None)
Dim MyPage As Page = mymergedoc.Pages(0)
Dim myx, myy, myheight, mywidth As Short
Dim myfontsize As Single
myx = MyPdfDocument.Form.Fields("ProductNumber").GetX(MyPage)
myy = MyPdfDocument.Form.Fields("ProductNumber").GetY(MyPage)
myheight = MyPdfDocument.Form.Fields("ProductNumber").Height
mywidth = MyPdfDocument.Form.Fields("ProductNumber").Width
myfontsize = mymergedoc.Form.Fields("ProductNumber").FontSize
This code errors out on the the GetX line. It is as if the field object is null.
I have double checked the fieldname, and I have tried to reference using an index value (0) instead of a name with no luck. Am I referencing the field object correctly? Any suggestions?
Thanks
Accessing form fields on a lifecyle 7 form pdf
Re: Accessing form fields on a lifecyle 7 form pdf
Support · Aug 21, 2012Hello,
Can you please send over the following details to our [^a|mailto:support@cete.com|opennewwindow|support^] team so that they can look into it further?
1. Input PDF document with which you are having problem in getting form field properties.
2. Full stack trace of the error message.
3. Exact version and build number of the DynamicPDF dll file which you are using in your application.
Thanks,
ceTe Software Support Team.
Re: Accessing form fields on a lifecyle 7 form pdf
Support · Aug 21, 2012Hello,
The form fields on the acro PDF form you sent are included inside multiple container fields. So you would need to use the full form field name (see sample code below) or parse the child field collection to obtain the actual form field object that you have to read the properties of.
Dim MyPdfDocument As PdfDocument = New PdfDocument("form1.pdf")
Dim mymergedoc As MergeDocument = New MergeDocument(MyPdfDocument, MergeOptions.None)
Dim MyPage As Page = mymergedoc.Pages(0)
Dim myx, myy, myheight, mywidth As Short
Dim myfontsize As Single
Dim field As PdfFormField = MyPdfDocument.Form.Fields("form1[0].#pageSet[0].Page1[0].Productname[0]")
myx = field.GetX(MyPage)
myy = field.GetY(MyPage)
myheight = field.Height
mywidth = field.Width
myfontsize = field.FontSize
If you want to go the route of parsing the child field collection, please refer to the Acro Form Reader example provided in the product download.
Also keep in mind that the product fully supports acro or static PDF forms. It does not support dynamic PDF forms. Both acro and dynamic PDF forms can be created using Adobe Lifecycle designer.
Thanks,
ceTe Software Support Team.