Merging PDFs

I recently had the need to merge some PDF scans into a single document. Since I use Ubuntu as my primary workstation and network storage machine- I wanted to work out a solution there (plus I could script it for future use if needed.

The tool to use is Ghostscript. On my fairly stock install, I did not have to install anything.

Here is a command example to combine three PDF files into one:

docs> gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=outfile.pdf infile01.pdf infile02.pdf infile03.pdf

The combined file is even smaller than the combined size of the input file, which is great.