PDF Form Template

I am using PDF form as a template to populate information such as customer name and address. I need to be able to batch create these. I was wondering if there was a way to load in the PDF and use it as a template, clone the template, fill in form fields and save the output to a new file. Under the current model, I need to open a PDF, fill in form fields, save output.


As this process is very expensive (takes approx 2.3 seconds per document) I was hoping that I could clone the document in memory (as Aspose Word provides for word documents), and use the clone to fill out form fields and save.

Thanks

Hello Viraf,

Thanks for your interest in our products.

When using Form class to fill the data inside form fields, the information is not populated inside the original document but internally, Aspose.Pdf.Kit for Java creates the copy of document, populates the data/information inside the form fields and then save the updated document with new name. Please visit the following link for further details on How to Fill Form Fields With API?

In case you still encounter any issues i.e. Fields are not populating, slow performance, missing data etc, please share the source PDF document and the code snippet that you are using, so that we can test the scenario at our end. We apologize for your inconvenience.

The issue is that I want to :


Load template
loop to as many records I have
fill form fields
save pdf with fields filled
end loop

The problem is that each time through the loop I do not want to load the PDF form from scratch. The examples provided specify input and output file when defining the form, or call the save. Maybe another example would be useful.

Hello Viraf,

Thanks for sharing the details.

Please note that Aspose.Pdf.Kit for Java loads the PDF document at once and then you can populate the data inside the form fields, as per your requirement and then save the resultant PDF document. Currently Aspose.Pdf.Kit for Java does not support the feature to iterate through the form fields individually and then populate the information inside them. In order to fill the form fields, you do not need to loop through the fields but you can simply fill in the data using field name.

By the way if you need to get the information of form field names before entering information inside them, please take a look over [Identifying form fields names ](http://www.aspose.com/docs/display/pdfkitjava/Identifying+form+fields+names)

In case I have not properly understood your requirement or you have any further query, please feel free to contact. We are sorry for this inconvenience.

Thanks - it appears that I was not clear in my question.


I have a PDF document that has form fields. I plan to use this document as a template for mail merge. So, for each record in my data set, I apply the form fields to the PDF and save the output as a separate file. In order to improve performance, I would like to cache the template, clone it for each data set apply form fields to the cloned version, save the cloned version as a separate document. This is similar to how the word version of Aspose works.

Thanks

Hello Viraf,


Thanks for sharing the details.

I am afraid currently Aspose.Pdf.Kit for Java does not support the feature to create a clone of source/input PDF document. In order to add the Form Fields, you need to load the PDF form on every attempt. However for the sake of implementation, I
have logged this requirement in our issue tracking system as
PDFKITJAVA-33197. We will investigate this requirement in details and will
keep you updated on the status of a correction.

We apologize for your inconvenience.