LinuxCommandLibrary

pdfjoin

Merge multiple PDF files into one

TLDR

Merge two PDFs into one with the default suffix "joined"

$ pdfjoin [path/to/file1.pdf] [path/to/file2.pdf]
copy

Merge the first page of each given file together
$ pdfjoin [path/to/file1.pdf path/to/file2.pdf ...] [1] --outfile [output_file]
copy

Save pages 3 to 5 followed by page 1 to a new PDF with custom suffix
$ pdfjoin [path/to/file.pdf] [3-5,1] --suffix [rearranged]
copy

Merge page subranges from two PDFs
$ pdfjoin /[path/to/file1.pdf] [2-] [file2] [last-3] --outfile [output_file]
copy

SYNOPSIS

pdfjoin [-o outfile.pdf] [infile1.pdf [infile2.pdf ...]]

PARAMETERS

-o, --outfile FILENAME
    Specify output PDF file; defaults to 'pdfjoin-#.pdf'

--keepinfo
    Retain PDF Info dictionary and metadata from first input

--papersize NAME
    Set paper size (e.g., 'a4paper', 'letterpaper')

--paperw WIDTH
    Set paper width in bp, pt, in, cm, mm, dd, pc, ex, em

--paperh HEIGHT
    Set paper height (units as above)

--help
    Display usage summary

--version
    Show version information

--
    End of options; treat remaining args as files

DESCRIPTION

pdfjoin is a utility from the pdfjam suite that concatenates two or more PDF files into a single output PDF. It leverages LaTeX's pdfpages package and pdfTeX to handle the merging process, preserving page order and most document properties. Unlike binary PDF tools, it reprocesses pages through LaTeX, which can embed fonts and ensure compatibility but may increase file size.

Usage is straightforward: list input files followed by an output specification. It supports options for paper size adjustments, metadata retention, and verbosity. Ideal for users in LaTeX environments needing reliable PDF assembly, though slower than native tools like pdftk for large files. Requires TeX distribution with pdfpages.sty.

CAVEATS

Requires LaTeX (pdfTeX) and pdfpages.sty; output may be larger due to font embedding; slower for many/large files vs. binary tools.

EXAMPLE

pdfjoin report1.pdf report2.pdf -o combined.pdf
pdfjoin --keepinfo --papersize a4 *.pdf -o all.pdf

DEPENDENCIES

texlive-latex-extra (or equiv.); pdftex; pdfpages.sty

HISTORY

Part of pdfjam suite by David Firth (2001+); wraps pdfpages (2000) for easy PDF manipulation via LaTeX; widely used in academic/TeX communities.

SEE ALSO

pdfunite(1), pdftk(1), qpdf(1), gs(1)

Copied to clipboard