Joining PDFs with Linux command line
There are several ways to merge two (or more) PDF files to a single file using the Linux command line.
If you're looking for graphical tools to edit or annotate a PDF, we have a separate card for that.
pdfjoin binary from pdfjam is probably already installed on your system. Usage:
pdfjoin one.pdf two.pdf --outfile out.pdf
Pages from joined documents might be rotated. To avoid this, call it like this:
pdfjoin one.pdf two.pdf --outfile out.pdf --paper a4paper --rotateoversize false
For a list of availble options use
PDFtk is another great toolkit for manipulating PDF documents. You may need to install it first (
sudo apt install pdftk).
Merging multiple files works like this:
pdftk one.pdf two.pdf cat output out.pdf
Unlike pdfjam, PDFtk should not mess with page sizes but simply joins pages as they are.
pdftk --help or the PDFtk examples page for more.
ImageMagick (not recommended)
You could also use ImageMagick's
convert, but this will raster vector contents and usually result in lower quality at higher file size:
convert one.pdf two.pdf out.pdf
We don't recommend this.