Trying to fill a form field in a PDF document that was created with Adobe LifeCycle Designer Not Working

I am looping through a set of datarows that contain the field name/value pairs and getting an error that the field name does not exist. And I know for sure that it does.

This is the code that I am using.

For Each dr As DataRow In ds.Tables(0).Rows

Dim pdfField as TextBoxField = TryCast(pdfDocument.Form(dr.Item("FieldName")), TextBoxField)

pdfField.Value = dr.Item("FieldValue")

Next

I think my problem is similar to one that was posted in February of 2012.

(My test was to get the name of the field and fill in the associated formfield box with the name of the box so that I would have all my field names for the view I would build to go with it. However the collection is only returning topmostSubform(0) as the field name and it fills in ALL the form fields with the same value. I've opened up the document in Adobe and each field does have a different name. For example the first field is name, the second dob, etc. My test was to get the name of the field and fill in the associated formfield box with the name of the box so that I would have all my field names for the view I would build to go with it. However the collection is only returning topmostSubform(0) as the field name and it fills in ALL the form fields with the same value. I've opened up the document in Adobe and each field does have a different name. For example the first field is name, the second dob, etc. )

I tried looping through my fields and get the topmostSubform(0) field and nothing else. Unfortunately, I am having difficulty translating your C# response to VB.NET.

Thanks,

Diane

Hi Diane,


Thanks for your inquiry. Please share your sample PDF form here, so we will look into it and will provide you more information accordingly.

We are sorry for the inconvenience caused.

Best Regards,

I have attached my PDF form for your review.

Thanks, Diane

Hi Diane,


Thanks for your inquiry. Please check following code snippet to access XFA data and filling it. Hopefully it will help you accomplish the task.

Dim pdfDocument11 As New
Document(myDir + “UMPF+2752+OK.pdf”)<o:p></o:p>

For Each field As String In pdfDocument11.Form.XFA.FieldNames<o:p></o:p>

Console.WriteLine(field)<o:p></o:p>

pdfDocument11.Form.XFA(field) = “test”<o:p></o:p>

Next<o:p></o:p>

Console.ReadKey()<o:p></o:p>

pdfDocument11.Form.XFA(“topmostSubform[0].Page1[0].polper[0]”)
= “Diane”<o:p></o:p>

pdfDocument11.Form.XFA(“topmostSubform[0].Page1[0].schpolnum1[0]”)
= “007”<o:p></o:p>

pdfDocument11.Form.XFA(“topmostSubform[0].Page1[0].schtopol1[0]”)
= “Full”<o:p></o:p>

pdfDocument11.Form.XFA(“topmostSubform[0].Page1[0].schco1[0]”)
= “Grinnell Mutual Reinsurance”<o:p></o:p>

pdfDocument11.Save(myDir + “XFAForm_out.pdf”)<o:p></o:p>

Please feel free to contact us for any further assistance.


Best Regards,

So I will have to somehow keep track of what page number my field is on, because the Submit XML does not contain the full field name. Is this true? Or is there a way for the XML to have the full field name?

Thanks, Diane

Hi Diane,


In order to fill the form field, you need to keep track of page number containing particular XFA field which you need to fill. May be you can first parse the complete XFA form, traverse through all the pages and get the fields present over particular page.

In case I have not properly understood your requirement or in the event of any further query, please feel free to contact.

Thank you for your help.

I was hoping to avoid that work around. But I will use it as my Plan B.

Thanks again for your assistance.

Diane