Object reference not set to an instance of an object

Object reference not set to an instance of an object

Forum member · Oct 18, 2006
Hi, I'm getting a null reference exception at the DrawToWeb method. I'm merging a template PDF, and I add the page based on the number of times needed. On each add, i fill in the form field values, and then use a DrawToWeb method. A quick portion of the code is shown below. I've double checked all the field names, and i do not get a null reference when im setting the values, only at the draw method. Please help. Dim myTemp As PdfDocument = New PdfDocument(MapPath("JobTicket3.pdf")) Dim myDoc As MergeDocument = New MergeDocument ds = clsJob.GetJobsByOrder While i < ds_jobs.Tables(0).Rows.Count Dim sPrefix As String = "pre" & i & "." Dim Options As MergeOptions = New MergeOptions(True, "pre" & i) myDoc.Append(myTemp, Options) myDoc.Form.Fields(sPrefix & "txtCompany").Value = ds.Tables(0).Rows(0).Item("Company") myDoc.Form.Fields(sPrefix & "txtAddress").Value = ds.Tables(0).Rows(0).Item("Address") myDoc.Form.Fields(sPrefix & "txtCity").Value = ds.Tables(0).Rows(0).Item("City") myDoc.Form.Fields(sPrefix & "txtState").Value = ds.Tables(0).Rows(0).Item("StateCode") myDoc.Form.Fields(sPrefix & "txtZip").Value = ds.Tables(0).Rows(0).Item("ZipCode") myDoc.Form.Fields(sPrefix & "txtEmail").Value = ds.Tables(0).Rows(0).Item("Email") myDoc.Form.Fields(sPrefix & "txtPhone").Value = ds.Tables(0).Rows(0).Item("Phone") myDoc.Form.Fields(sPrefix & "txtFax").Value = ds.Tables(0).Rows(0).Item("Fax") myDoc.Form.Fields(sPrefix & "txtCountry").Value = ds.Tables(0).Rows(0).Item("Country") '//Add some more dynamic elements based on other datasets... myDoc.Pages(i).Elements.Add(New Label(sProductElement.ToString(), 64, 3 + YOffset, 292, 12, Font.Helvetica, 12)) myDoc.Pages(i).Elements.Add(New Label(sProductElementValue, 364, 3 + YOffset, 82, 12, Font.Helvetica, 12, TextAlign.Right)) i += 1 End While myDoc.DrawToWeb("test.pdf") Response.End()

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

Support · Oct 19, 2006
Hello, Can you please make sure that you are using the latest DLL files from the web site. If you have a license, please log into the Customer Area using your serial number and download the latest DLL files. The error likely occurs when you are filling PDF forms and one of the form field name is incorrect or the value being assigned for the form fields is null. Can you please verify all the field names once again by running the FormFieldReader example downloaded with the product and using your PDF document as template. Thanks, ceTe Software Support Team

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

Forum member · Oct 19, 2006
Thanks. I didn't realize that passing a null string (even just a "") is not acceptable in the acro form field. a simple validation for those null values fixed the problem. Thank you.