Hello,
I'm trying to add a dynamically generated cover page, along with a
header/footer, to existing PDFs and I need some help. What I would like to
do is:
1. Create an in memory Document with one or more pages with some text on
them (Cover page).
2. Open an existing PDF document.
3. Take each page of the existing PDF document and append it to the in
memory document while adding header/footer text to each appended page.
4. Write out the newly created in memory document to file.
Here is some pseudocode showing how I'm trying to accomplish this with itext
(note I have not looked at the header/footer as of yet):
PdfReader reader = new PdfReader(existingPDF);
Document doc = new Document(reader.getPageSize(1));
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream(newPDF));
doc.open();
// begin cover page(s)
doc.add(new Paragraph(text)); // adding content to cover page(s)
// add other content (paragraphs/images) as needed
...
// finished with cover page(s)
// append pages of existingPDF to doc
int numPages = reader.getNumberOfPages();
for (int i = 1; i <= numPages; i++)
{
byte[] b = reader.getPageContent(i);
doc.newPage();
doc.add(b); // (pseudocode)...trying to add the content
represented by b
to doc
// somehow add header/footer to this new page at this point
}
// finished appending pages from existingPDF to doc
doc.close(); // write doc out to file
Obviously I'm an itext nube...if anyone has some suggestions or pointers I'd
appreciate it.
Thanks,
Adam
--
View this message in context:
http://www.nabble.com/Adding-Cover-Page-and-Header-Footer-to-Existing-PDF-tp20213336p20213336.html
Sent from the iText - General mailing list archive at Nabble.com.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php