Posted 6 months ago. Visible to the public.

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.


The 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 pdfjam --help.


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.

See pdftk --help or the PDFtk examples page for more.

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.

Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Owner of this card:

Judith Roth
Last edit:
6 months ago
by Arne Hartherz
concat, concatenate
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Judith Roth to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more