1

I'm learning about Java and iText API to generate PDF reports. What I want is very simple: add a Paragraph to my PDF file (Report.pdf). It works perfectly in my code:

doc = new Document(PageSize.A4.rotate());
PdfWriter.getInstance(doc, new FileOutputStream("Report.pdf"));
doc.open();
doc.add(new Paragraph("One!"));

Now I want to add my Paragraph in the end of file if Report.pdf exists. I've tried to use true in FileOutputStream as a 2nd parameter but it didn't work. I suspect is because of my line one generates an empty document, but I'm not sure. Does anyone knows how to solve it?

El Mestre
  • 85
  • 10
  • http://stackoverflow.com/questions/23062345/function-that-can-use-itext-to-concatenate-merge-pdfs-together-causing-some – Reimeus Oct 30 '16 at 18:04
  • 1
    Adding content to an existing PDF is done with `PdfStamper` not with `PdfWriter`. Also: PDF isn't a word processing format, so you shouldn't expect the layout to automatically adapt to the new content. All existing content is added at absolute positions. If you want to add extra content "at the end", you have to find out the coordinates of "the end" first. – Bruno Lowagie Oct 31 '16 at 07:15

0 Answers0