I am creating a document from scratch, adding an existing PDF, adding more content from scratch, then adding another PDF.
I am trying to pass a page number to form fields on the existing PDF's. The content created on the fly is getting the right page numbers and is accounting for the number of pages in the PDF's in between.
What I need to do is pass a number to each of the PDF's (by form field I believe) and make sure that the section sequence remains intact (just one continuous section).
I am using
document = new MergeDocument(...);
Template template = new Template();
template.Elements.Add(new PageNumberingLabel("%%CP%%", 690, 520, 690, 520, Font.TimesRoman, 9));
document.Sections.Begin(NumberingStyle.Numeric, template);
Thanks for the advice
Page numbers and form fields
Re: Page numbers and form fields
Support · Jul 22, 2009Hello,
Following is the sample code that shows how to add page numbers to the appended PDF document:
MergeDocument document = new MergeDocument();
// Create a template object and add a page numbering label
Template template = new Template();
template.Elements.Add( new PageNumberingLabel( "%%SP%% of %%ST%%", 0, 680, 512, 12, Font.Helvetica, 12, TextAlign.Center ) );
// Begin the first section
document.Sections.Begin( NumberingStyle.RomanLowerCase );
// Add two pages
document.Pages.Add( new Page() ); //Page 1
document.Pages.Add( new Page() ); //Page 2
// Begin the second section
document.Sections.Begin( NumberingStyle.Numeric, template );
// Add three pages
document.Pages.Add( new Page() ); //Page 3
document.Pages.Add( new Page() ); //page 4
document.Pages.Add( new Page() ); //page 5
// Begin the third section specifying a section prefix
document.Sections.Begin( NumberingStyle.RomanLowerCase, "Appendix A - " );
document.Append(@"C:\Temp\fw9AcroForm_03.pdf");
// Save the PDF
document.Draw( @"C:\MyDocument.pdf" );
Thanks,
ceTe Software Support Team
Re: Page numbers and form fields
Forum member · Jul 22, 2009Nope, that failed miserably.
A) this did not even come close to answering my question about form fields
and
B) throws a run time error using
document.Append(@"C:\Temp\fw9AcroForm_03.pdf");
I need some page numbers on an existing PDF (one of several) that is getting merged into what will become my final document.
I have fields set up on the pages and would like to pass something to them so they iterate page numbers.
If form fields are unnecessary, great. I just don't see numbers going on to static pages.
Please advise.
Re: Page numbers and form fields
Support · Jul 22, 2009Hello,
The reason you are getting the error is becasue the path to the file used in the Append method does not exist on your end. That was just an example. You will have to change the name of the PDF document in the Append method to the one you are using to append.
If you want to populate a value in the form field, then you will have to keep track of what page you are on when doing the form filling.
Easier solution would be to not use form fields and add static page numbers dynamiccally at runtime using the PageNumberingLabel page element. It will add the page numbers in order to all the pages that exsit in the document.
Thanks,
ceTe Software Support Team