How could I merge / convert multiple PDF files into one large PDF file?
I tried the following, but the content of the target file was not as expected:
convert file1.pdf file2.pdf merged.pdf
I need a very simple/basic command line (CLI) solution. Best would be if I could pipe the output of the merge / convert straight into pdf2ps
( as originally attempted in my previously asked question here: Linux piping ( convert -> pdf2ps -> lp) ).
The other answers are good, but if you cannot merge PDFs locally, whether you are in a shared hosting environment, or for other reasons, they will not help you.
If you are looking for an API to merge PDFs remotely, you can try api2pdf which has an endpoint for merging pdfs together. Documentation is here.
I'm sorry, I managed to find the answer myself using google and a bit of luck : )
For those interested;
I installed the pdftk (pdf toolkit) on our debian server, and using the following command I achieved desired output:
OR
This in turn can be piped directly into pdf2ps.
This is the easiest solution if you have multiple files and do not want to type in the names one by one:
qpdf --empty --pages *.pdf -- out.pdf
Considering that
pdfunite
is part of poppler it has a higher chance to be installed, usage is also simpler thanpdftk
:Also
pdfjoin a.pdf b.pdf
will create a newb-joined.pdf
with the contents of a.pdf and b.pdf