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.
PDFtk (recommended)
PDFtk is a 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.
See pdftk --help
or the
PDFtk examples page
Show archive.org snapshot
for more.
pdfjam
This is another option. You may need to install it first: sudo apt install texlive-extra-utils
(has many dependencies).
Usage:
pdfjam --outfile out.pdf one.pdf two.pdf
Pages from joined documents might be rotated. To avoid this, call it like this:
pdfjam --outfile out.pdf --fitpaper true --paper a4paper --rotateoversize false one.pdf two.pdf
For a list of availble options use pdfjam --help
.
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.