Populating a PDF Form using aspose

Hello,

We have a requirement to generate PDF from a fillable PDF form with user input data. Currently we are doing a similar requirement with word templates and using mailmerge we populate the data and create a PDF. However, this requirement, we have to use PDF forms. Could you please let us know if there is a way to achieve this requirement. Attached a sample form.f1040.pdf (344.1 KB)

Thanks,
B

@judiciary

As per our understandings, you need to fill the data in the PDF as per the information provided by the user and after that, you want to save the filled PDF. In case our understandings are correct, you can use Aspose.PDF in order to fill the form fields and once it is filled, you can flatten the fields to distribute or save the final PDF.

Hello,

With the link provided in your response above, we can populate the data in form fields using field name lookup. We have multiple forms and lots of fields in each form. If we go with this approach, we have to loop through each field and then update.

Is there an option to use an xml input and populate the form fileds by xml node and not having to go through each form field, like we do in mailmerge. If yes, could you please share sample input pdf, xml file and output for this scenario.

Thanks,
B

@judiciary

You can surely import data from XML into PDF forms. Please check the linked code example and you can find used file in our demo project hosted over GitHub.

Hello,

Thank you for your response. However, we were unable to locate those examples in the aspose github. We downloaded the master branch and could not locate any of the files mentioned in this example. If you could attach those files referred here, that will be helpful.

Thanks
B

@judiciary

You can please find the sample XML file in other GitHub Project. This is a sample file that you can use to have an idea of how an XML template should look like in order to import form values in PDF.