Object reference not set to an instance of an object.

Object reference not set to an instance of an object.

Forum member · Dec 22, 2006
I'm trying to populate a pdf with webform/textbox data. I created a pdf with textboxes and a webform with the following code. I'm getting the following error. "Object reference not set to an instance of an object." This error points to any one of the form fields. I'm I missing something in the pdf? Do I have to set something in the pdf? Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If IsPostBack Then ' Create a document and set it's properties Dim MyDocument As MergeDocument = New MergeDocument(MapPath("Documents/Form.pdf")) MyDocument.Creator = "MotorcraftPartsForm.aspx" MyDocument.Author = "Jim Kiely" MyDocument.Title = "Motorcraft Parts" ' Get the imorted MyPage and set margins. Dim MyPage As ceTe.DynamicPDF.Page = MyDocument.Pages(0) ' Add content to the MyPage MyDocument.Form.Fields("txtGL508RMa").Value = txtGL508RMa.Text MyDocument.Form.Fields("txtGL508RMb").Value = txtGL508RMb.Text MyDocument.Form.Fields("txtGL485RMa").Value = txtGL485RMa.Text MyDocument.Form.Fields("txtGL485RMb").Value = txtGL485RMb.Text MyDocument.Form.Fields("txtGL500RMa").Value = txtGL500RMa.Text MyDocument.Form.Fields("txtGL500RMb").Value = txtGL500RMb.Text MyDocument.Form.Fields("txtGL496RMa").Value = txtGL496RMb.Text MyDocument.Form.Fields("txtGL481RMa").Value = txtGL481RMa.Text MyDocument.Form.Fields("txtGL481RMb").Value = txtGL481RMb.Text ' Outputs the W-9 to the current web MyPage MyDocument.DrawToWeb("Form_" & Date.Now() & ".pdf") Response.End() End If End Sub

Re: Object reference not set to an instance of an object.

Support · Dec 22, 2006
Hello, The error you are getting is most probably because of not using the correct name of the form field when accessing the form field. In order to access the form fields you will have to use the full name of the FormField. You can know the full names of the form fields of your PDF by using the FormFieldReader example downloaded with the product download using your PDF as template. Thanks, ceTe Software Support Team.

Re: Object reference not set to an instance of an object.

Forum member · Jan 2, 2007
Which example are you talking about? Also I'm using Acrobat Pro to create the form. I'm copy and pasting the formfield names into the vb code, so I'm still confused. Is there something in the form that that I need to enable?

Re: Object reference not set to an instance of an object.

Support · Jan 2, 2007
Hello, You will have to use the FormFieldReader example downloaded with the product download in order to know the full names of the form fields of your PDF document by using your PDF as a template. You can find this example in the folder [INSTALLDIR]\ceTeSoftware\DynamicPDF v4.0.2 for .NET Enterprise Edition\Examples. Thanks, ceTe Software Support Team.

Re: Object reference not set to an instance of an object.

Forum member · Jan 2, 2007
There has to be a problem with my pdf file, the name is exact I'm using the exact code from the example. Any ideas in the pdf what I need to be looking for?

Re: Object reference not set to an instance of an object.

Support · Jan 2, 2007
Hello, Can you please send over the PDF document and the code you are using to our [^a|mailto:support@cete.com|Support Team^] so that they can take a look at it and try to find out what is causing the problem. Thanks, ceTe Software Support Team.

Re: Object reference not set to an instance of an object.

Forum member · Aug 11, 2008
I'm having the same problem. How was this resolved?

Re: Object reference not set to an instance of an object.

Support · Aug 11, 2008
Hello, Can you please send over the PDF document and the code you are using to merge the PDF to our [^a|mailto:support@cete.com|Support Team^] so that they can take a look into it. Thanks, ceTe Software Support Team.

Re: Object reference not set to an instance of an object.

Forum member · Aug 11, 2008
I was able to resolve this issue. I ran the FormFieldReader example supplied with the software and got the results. For some reason, the names of my fields were all "name[0]" also all the fields were inside two container objects. The field names on the report were all like "F[0].P1[0].PolicyNumber[0]" icould not reference the field names as such wuith the code as given. I was able to reference the fields with the following code. Dim MyDocument As MergeDocument = New MergeDocument("C:\overdue1a.pdf") ' Set the field values Dim FieldList As ceTe.DynamicPDF.Forms.FormFieldList Dim FieldList2 As ceTe.DynamicPDF.Forms.FormFieldList FieldList = MyDocument.Form.Fields("F[0]").ChildFields FieldList2 = FieldList("P1[0]").ChildFields FieldList2("PolicyNumber[0]").Value = "120021" FieldList2("ReportMonth[0]").Value = "12" FieldList2("reportYear[0]").Value = "2007" FieldList2("no60DaysPastDueFlag[0]").Value = "Yes" Is there a more elegant way to do this? David

Re: Object reference not set to an instance of an object.

Support · Aug 11, 2008
Hello David, That’s the correct way of filling the form fields. You have to specify the full name of the form field when filling them with values. The [0] were appended because that’s the naming convention used by PDF documents created in Desginer. Thanks, ceTe Software Support Team

Re: Object reference not set to an instance of an object.

Forum member · Aug 11, 2008
Thank You