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

Free Support Forum - aspose.com

PDF XFA FORM import/Export script error

Hi Team,
We are evaluating the ASPOSE sample code for PDF XFA Form import and export options. But we are facing as issue as in mentio screenshot.
As we are analysing the tool for one of our major requirement, it will be helpful if we get a quick support on this issue to understand the feasibility of this tool.

Sample template is attaching here for the analysis from ASPOSE team side.

Requirement

  1. We want to fill this form controls with the values from database and save the form in a location. This generated form should have same signature as in the original file and all the events embedded in original file should be replicated.
  2. These forms have a validate button to ensure the correctness of the filled data and generate a barcode if all the filled data are valid and proper.

Issue in evaluation code downloaded from website.
• Signature not proper and script error also coming, bcoz of script error validate button and other events not working. Screenshot available in document

Sample code used for the testing

XFA PDF Import into XML-> Modify XML node text to bind values-> Import XML into PDF and generate new pdf. Screenshot available in document

XFA FORM Generation.docx (653.7 KB)

imm1294e-original.pdf (583.5 KB)

@asposectsimmg

Can you please share the used xfdf file so that we may try to reproduce the same on our end.

InputFiles.zip (1.2 MB)

Input PDF and XFDF file also attached here.

Same i had XML also. These XFDF/ XML files i generated using the ASPOSE Export option only and same i am trying to import and create new pdf file.

@asposectsimmg

I am getting XmlException with latest version of the API. We will check it further and share our feedback. However, please try to save the document incrementally by calling the Save method as under, and then share your feedback.

form.Save();

Hi Team,
I was using the same sample code given by aspose using the below line of code.
form.Save(dataDir + “imm1294 (Study Permit)- Edited (002)-xfdf_out-GENERATED.pdf”);

I am not getting how i can call .Save method multiple times for incremental changes. Please share sample code to understand the same.

Do you have any update on the XMLexception mentioned last time?

@asposectsimmg

We are looking into the exception. You can call the Save method without passing any parameters, neither the file name or path. It will update the source PDF file without creating an additional file. I suggest you to please visit Document.Save Method for your convenience and share your feedback.

form.Save();

Sorry, I am unable to fix it. Please share the code snippet to make correction in my end check. Thanks!.

@asposectsimmg

I request you to try this code and share your feedback.

Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();
// Open Document
form.BindPdf(dataDir + "imm1294e-original.pdf");

// Open xfdf file.
System.IO.FileStream xfdfInputStream = new FileStream(dataDir + "imm1294 (Study Permit)- Edited (002).xfdf", FileMode.Open);

// Import data
form.ImportXfdf(xfdfInputStream);

// Close file stream
xfdfInputStream.Close();

// Save updated document
form.Save();

Hi,
I have checked the same code you posted, unfortunately the same is throwing an exception for me. Attached the screenshot for your reference. aspose-error-1.JPG (44.4 KB)

I have checked the similar code for XML also, it executed without error but the pdf file not getting any expected changes. Please help with a proper solution.

@asposectsimmg

There is some confusion with your scenario. I can not reproduce the issue as explained in your Docx file while using the same code shared by you. Please elaborate how you are creating the PDF file which is having signature and script error. I request you to paste the code here instead of the snapshot.