Hi,
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.BindPdf(newFilename);
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.
Thanks!
Hi Tero,
Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();<o:p></o:p>
pdfForm.BindPdf("c:/pdftest/NoJS.pdf");
pdfForm.FillField("tx102", "100");
pdfForm.Save("c:/pdftest/NoJS_Filled.pdf");
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?
Regards,
Tero
Hi Tero,
evaluation version has two limitations, evaluation watermark and at most
four elements of any collection can be viewed. Please make a request for 30
days 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,