Concatenate PDFs on the Command Line

January 12, 2017

Concatenate PDF’s on the Command Line

I used to use pdfchain to concatenate PDF files. It’s a GUI based program that gets the job done and can do a few other things as well.

But for simple concatenating jobs, it’s just easier, and quicker, to use the command line.

There’s a couple of programs that I routinely use: gs (ghostscript) and pdftk.


To concatenate PDF files using ghostscript, execute the following on the command line:

gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite
-sOutputFile=output.pdf file-01.pdf file-02.pdf [...] file-nn.pdf

Obviously an alias might be something to use for this command.


There’s also the very handy PDF utility program called pdftk, which is equally easy to use from the command line.

To concatenate all the PDF files in the current directory into one PDF file:

pdftk *.pdf cat output output.pdf

To concatenate specific PDF files into one:

pdftk file-01.pdf file-02.pdf [...] file-nn.pdf cat output output.pdf

Sometimes you need to do the opposite of concatenating, in other words, splitting up a PDF by pages.

To split a large PDF file into many one-page PDF files:

pdftk large_PDF_file.pdf burst

which will burst, or split up, the original file into many smaller PDF files commeasurate with the number of pages in the original large PDF file.

comments powered by Disqus