I am using the PDF merger control for generating PDF files.
I have say 1000 employees and I have to generate 1000 pages (1000 PDF forms for each individual employee) but in a single PDF. How to do that?
I am using a template of a PDF form
string formPath = ConfigurationSettings.AppSettings["1099PDFTemplate"];
MergeDocument document = new MergeDocument(@formPath);
This PDF template is filled using the code which is looped to generate 1000 PDF forms for 1000 employees.
For e.g.
document.Form.Fields["RecipientName"].Value = payeeName;
I want these 1000 PDF forms as a 1000 paged single PDF file.
So how can I add 1000 pages in one single file?
new pages in MERGER
Re: new pages in MERGER
Support · Nov 7, 2008Hello,
Yes you can generate individual pages for each employee and you can merge them into a single pdf without any problem using our DynamicPDF product. The efficient way to do this is append all the documents and create a main PDF and then you can fill the form fields from the main PDF.
If you are using the same PDF to merge multiple times then you will have to use the MergeOptions class to rename the form fields when appending the PDFs. You will have to fill the form fields using the new names. The following is the sample to do this.
//Create the pdfDocument from template
PdfDocument pdfDoc = new PdfDocument( "path of the PDF" );
//Create a main PDF document
MergeDocument document = new MergeDocument();
//Append the Template PDF in the loop
for (int j = 0; j < recordcount ; j++)
{
//Create MergeOptions to reorganize the field names
MergeOptions options = new MergeOptions(true, j.ToString() );
//Append the pdfDoc to the main PDF
document.Append( pdfDoc , options );
}
//Fill the form fields using their changed names in the main PDF.
document.Form.Fields["NewName"].Value = "ceTe Software";
//save the PDF
document.Draw(@"C:\Temp\output.pdf");
Thanks,
ceTe Software Support Team.
Re: new pages in MERGER
Forum member · Nov 7, 2008Thanks for the reply.
But wouldn't I need to fill the fields in the loop as well?
What will be the changed names? and how will the PDF recognize this new names?
The field names are pre-defined on the PDF template. How to change these names through the code? can you give me some example...
my code to fill is as given below:(this code is in the loop for 100 records)
MergeOptions options = new MergeOptions(true,j.ToString());
document.Append(pdfDoc, options);
foreach (DataRow _dr in foundRows)
{
fld1= _dr["fld1FrmDB"].ToString();
fld2= _dr["fld2FrmDB"].ToString();
fld3= _dr["fld3FrmDB"].ToString();
fld4= _dr["fld4FrmDB"].ToString();
document.Form.Fields["fldToFill1"].Value = fld1;
document.Form.Fields["fldToFill2"].Value = fld2;
document.Form.Fields["fldToFill3].Value = fld3;
document.Form.Fields["fldToFill4"].Value = fld4;
}
Re: new pages in MERGER
Support · Nov 7, 2008Hello,
You can fill the form fields from the loop without any problem. You can reorganize the form fields and that will give you control over the field names that exist several times. You do not rename the entire form field, you only append a string to the beginning.
Following is the link to the Help Documentation on our web site that shows how to Fill Reorganized Acro Form Fields
.
Thanks,
ceTe Software Support Team
Re: new pages in MERGER
Forum member · Nov 7, 2008Thank you very much for the quick support. The code's now functioning as desired