1

I'm looking to Concat/Merge multiple PDFs into one PDF. Each original PDF needs to start on a new page in the final PDF. In addition, I need to add a footer to each page of the final PDF that has a file identifier on the left, Page X of Y in the center, and time stamp on the right. When using iTextSharp, I could use a PDFWriter, modify the Page Event Handler, and create a footer table. Is this the simplest way to create the footer? When I built a table, I'm having issue with the total number of the "Page X of Y". How do you generate the Y in a table?

public override void OnEndPage(PdfWriter writer, Document doc)
{
    PdfPTable footerTable = new PdfPTable(3);

    footerTable.TotalWidth = doc.PageSize.Width;

    footerTable.HorizontalAlignment = Element.ALIGN_CENTER;

    Paragraph documentID = new Paragraph("Document ID: " + docID, footer);

    Paragraph pageNumbers = new Paragraph("Page " + writer.PageNumber.ToString() + " of " + **Y**, footer);

    Paragraph time = new Paragraph(timeStamp, footer);
}

As for using PDFWriter to merge the documents, will it give me a page break at the start of each document that is next to be written to the final PDF?

puretppc
  • 3,232
  • 8
  • 38
  • 65
Coreman
  • 31
  • 1
  • 5
  • For the *Page X of Y* I recommend just running another pass once everything's combined. See this for a discussion: http://stackoverflow.com/a/9845722/231316 – Chris Haas Jan 21 '14 at 21:57
  • For merging documents, use PdfCopy, not PdfWriter. – mkl Jan 22 '14 at 05:50

0 Answers0