We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

NullReferenceException when filling a form with JavaScripts removed


I have a PDF file that originally had some JavaScript in it. I have removed all JavaScript with these lines of code:

var stripper = new Aspose.Pdf.Facades.PdfJavaScriptStripper();
stripper.Strip(fromFilename, newFilename);

Then, I try to fill in some form data to this stripped PDF with these lines of code:

Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();
pdfForm.FillField(“tx102”, “0”);

It gives NullReferenceException. Here’s the stack trace:

at Aspose.Pdf.InteractiveFeatures.Forms.Field. (String )
at Aspose.Pdf.InteractiveFeatures.Forms.Field.Recalculate()
at Aspose.Pdf.InteractiveFeatures.Forms.Field.get_Value()
at Aspose.Pdf.InteractiveFeatures.Forms.TextBoxField.set_Value(String value)
at Aspose.Pdf.Facades.Form.FillField(String fieldName, String fieldValue)

Attached is the PDF file with JavaScript stripped. How to set a value into the field “tx102”? I’m running version 9.0.0.


Hi Tero,

Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 11.3.0 and I am unable to notice any issue. As per my observations, the PDF file is properly being filled. For your reference, I have also attached the output generated over my end. Can you please try using the latest release and share your findings. We are sorry for this inconvenience.


Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();<o:p></o:p>


pdfForm.FillField("tx102", "100");


Thank you for the reply!

I tested with versions 11.3.0 and 11.4.0 and indeed FillField doesn’t crash anymore. But nothing appears in the resulting PDF, the field remains empty. I see that in your output the field is indeed correctly filled. I tested filling some other fields, and only a couple of them will have their values visible in the PDF.

My license covers only 10.3.0 (and it also crashes when filling “tx102”). So I tested without a license. Does it have an effect to what form fields can be output to the PDF file?



Hi Tero,

Thanks for your feedback. Yes testing without a valid license can have issue, as Aspose.Pdf
evaluation version has two limitations, evaluation watermark and at most
four elements of any collection can be viewed. Please make a request for 30
temporary license and implement it to evaluate our product without
any limitation, It will resolve the issue.

Please feel free to contact us for any further assistance.

Best Regards,