Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I merge individual selected PDF files into one PDF upon download?

How can I merge individual selected PDF files into one PDF upon download?

I want to achieve the following: http://annualreport2010.landsecurities.com/create-your-own-report.aspx

Do I require an ASP website, or could I do something similar using a static HTML site?

like image 843
JV10 Avatar asked Nov 28 '11 03:11

JV10


2 Answers

Static HTML won't do it.

You need something on the server side. The other answers have options that would work, I just wanted to also mention pdftk, which you could then call from the server side. Be sure to escape all file names and such, though, because you would have to use system calls.

pdftk is really easy. The very first example from their documentation shows how to merge several PDFs, named 1.pdf, 2.pdf and 3.pdf, into one PDF called 123.pdf:

pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf

For PHP, there even is pdftk-php, if you want to look into that.

like image 137
Christian Neverdal Avatar answered Sep 28 '22 11:09

Christian Neverdal


I think that the Apache PDFBox project can be good for you.

In particular, take a look at the PDFMerger class.

You can also use iText but in my opinion it's less easy to use.

like image 28
davioooh Avatar answered Sep 28 '22 09:09

davioooh