0

I need to merge several PDFs with Itext 5.5.6 and each PDF continues in the last page of the last pdf.

I try this but always insert content in a new page.

Document document = new Document();
PdfCopy copy = new PdfCopy(document, new FileOutputStream(ficheroDestino));

document.open();

PdfReader reader = new PdfReader(ficheroCabecera);
copy.addDocument(reader);
copy.freeReader(reader);
reader.close();

reader = new PdfReader(ficheroContenido);
copy.addDocument(reader);
copy.freeReader(reader);
reader.close();

reader = new PdfReader(ficheroPie);
copy.addDocument(reader);
copy.freeReader(reader);
reader.close();

document.close();

How can I do it?

Thanks.

Lithorell
  • 101
  • 3
  • 1
    "each PDF continues in the last page of the last pdf" - what does it mean? clearly state your problem. – Wasi Ahmad Dec 13 '16 at 07:38
  • For example, if the first PDF ends at the middle of the page, the next pdf starts at this point, not in a new page – Lithorell Dec 13 '16 at 07:43
  • @pruebasNormalizadas You might be interested in something like the [PdfVeryDenseMergeTool](https://github.com/mkl-public/testarea-itext5/blob/master/src/main/java/mkl/testarea/itext5/merge/PdfVeryDenseMergeTool.java) from [this answer](http://stackoverflow.com/a/29078954/1729265). – mkl Dec 13 '16 at 07:54
  • It works. Many Thanks @mkl – Lithorell Dec 14 '16 at 07:47
  • Ok, so let's mark this question a duplicate of that other one. – mkl Dec 14 '16 at 07:59

0 Answers0