Posted 3 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.

pdfjam

The pdfjoin binary from pdfjam is probably already installed on your system. Usage:

Copy
pdfjoin one.pdf two.pdf --outfile out.pdf

Pages from joined documents might be rotated. To avoid this, call it like this:

Copy
pdfjoin one.pdf two.pdf --outfile out.pdf --paper a4paper --rotateoversize false

For a list of availble options use pdfjam --help.

PDFtk

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:

Copy
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:

Copy
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:

Avatar
Judith Roth
Last edit:
2 months ago
by Arne Hartherz
Keywords:
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