Search code examples
linuxpdfmergecommand-line-interface

Merge / convert multiple PDF files into one PDF


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) ).


Solution

  • 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:

    pdftk file1.pdf file2.pdf cat output output.pdf
    

    OR

    gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf file1.pdf file2.pdf file3.pdf ...
    

    This in turn can be piped directly into pdf2ps.