views:

534

answers:

2

I'm investigating how one can combine multiple PDF's into a single PDF.

I'm looking for a library that is as reliable and robust as possible. Preferable a library that can preserve bookmarks.

Ghostscript can concat where the bookmarks are preserved, but I experienced trouble where it in one case failed to generate any output.pdf.

gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf document1.pdf document2.pdf document3.pdf
GPL Ghostscript 8.54: Unrecoverable error, exit code 1
GPL Ghostscript 8.54: ERROR: A pdfmark destination page 36 points beyond the last page 1.

The same documents could I successfully merge with FPDI + TCPDF, however bookmarks wasn't preserved.

I'm worried choosing a solution that cannot merge some PDFs. What good/bad libraries do you have experience with?

+1  A: 

I have had good experiences with PDFsam. However, I did not pay attention to bookmark preservation, so you'd have to test it for yourself.

Frank
I just tried out PDFsam and it preserves bookmarks which is good.
neoneye
The problem is not so much to preserve bookmarks *per se* -- the problem starts when you try to *use* them in the merged output document: if the initial bookmarks had used absolute page numbers for targets, bookmarks in the merged file may still point to the same page number. And this will be wrong in may cases. It needs quite a smart program to merge 2 or more PDF files and have **updated** bookmarks work.
pipitas
+1  A: 

I have used pdftk to merge multiple PDF files, and I liked it a lot as it is simple to use. However, I am not sure if it preserves bookmarks, sorry. Could find out at a glance on the home page. If anyone knows, let me know.

Tom Bartel
pretty short and intuitive commandline syntax. nice
neoneye