Hello,
Please advise the proper methods to perform the following using C#:
- open a PDF form
- populate form fields
- repeat X times (looping through a recordset)
- save the concatenated form as a single file to a local directory
We’re looking for the fastest and most efficient method. I’ve reviewed the similar forum posts but have not seen exactly the solution I’m looking for.
Please advise.
Thank you.
Hi Marty,
Thank you very much for considering Aspose.
Please find below the answers to your questions:
- open a PDF form
Use Form class to open a PDF form, fill and then save it:
//First a input and output pdf files should be assigned
Form form = new Form(“inputForm.pdf”, “output.pdf”);
- populate form fields
Use FillField method to fill the individual form field:
//open input and outpput files
Aspose.Pdf.Kit.Form form = new Aspose.Pdf.Kit.Form(“inputForm.pdf”, “output.pdf”);
//fill fields
form.FillField(“FieldName1”,“Value1”);
form.FillField(“FieldName2”,“Value2”);
//save output file
form.Save();
- repeat X times (looping through a recordset)
If you want to fill multiple fields at the same time, you can build XML or FDF and then
use ImportXml or ImportFdf methods to fill all the fields at once.
Please see the following topics for detailed examples:
Import and Export into FDF
Import and Export into XML
If you want to fill the fields with the data from the database then you will have to use AutoFiller
class.
- save the concatenated form as a single file to a local directory
In order to concatenate multiple files into one you can use PdfFileEditor class. Please see the
following topic for details: Concatenate PDF Documents
I hope this helps. If you have any further questions, please do let us know.
Regards,