Hi,
I have read a PDF page, filled in the form, flattened it, added two more
pages using PDFCopy - and now I am unable to add more content. Can someone
tell me what I am doing wrong?
Here is what I have:
RandomAccessFileOrArray frontPage = new RandomAccessFileOrArray(
pdfFolder + "\\frontPage.pdf");
reader = new PdfReader(frontPage, null);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
stamper = new PdfStamper(reader, baos);
AcroFields form;
form = stamper.getAcroFields();
form.setField("userName1", userName1);
form.setField("userName2", userName2);
stamper.setFormFlattening(true);
stamper.close();
// got the first page, and filled the form
reader = new PdfReader(baos.toByteArray());
Document document = new Document(reader.getPageSizeWithRotation(1));
PdfCopy writer = new PdfCopy(document, baos);
document.open();
writer.addPage(writer.getImportedPage(reader, 1));
RandomAccessFileOrArray intro = new RandomAccessFileOrArray(
pdfFolder + "\\intro.pdf");
reader = new PdfReader(intro, null);
writer.addPage(writer.getImportedPage(reader, 1));
writer.addPage(writer.getImportedPage(reader, 2));
// added the next two pages...
Just doing
document.add(new Paragraph("blah"));
doesn't add any content at this stage.
I have tried using a PDFWriter, using the document as a parameter:
PdfWriter pdfWriter = PdfWriter.getInstance(document, new FileOutputStream(
outputFileName));
but that seems to start again, losing the first three pages.
I got the book, but I am still struggling ( I have a cold, that's my only
excuse!).
Can someone show me what I need to do just to add more paragraphs to what I
have created so far?
Thanks,
John
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/