LinuxCommandLibrary

pdfjam

Manipulate and combine PDF files

TLDR

Merge two (or more) PDFs

$ pdfjam [path/to/file1.pdf path/to/file2.pdf ...] [[-o|--outfile]] [path/to/output_file.pdf]
copy

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

Merge subranges from two PDFs
$ pdfjam [path/to/file1.pdf 3-5,1] [path/to/file2.pdf 4-6] [[-o|--outfile]] [path/to/output_file.pdf]
copy

Sign an A4 page (adjust delta to height for other formats) with a scanned signature by overlaying them
$ pdfjam [path/to/file.pdf] [path/to/signature] --fitpaper true [[-o|--outfile]] [path/to/signed.pdf] --nup "[1x2]" --delta "[0 -842pt]"
copy

Arrange the pages from the input file into a fancy 2x2 grid
$ pdfjam [path/to/file.pdf] --nup [2x2] --suffix [4up] --preamble '[\usepackage{fancyhdr} \pagestyle{fancy]}'
copy

Reverse the order of pages within each given file and concatenate them
$ pdfjam [path/to/file1.pdf last-1 path/to/file2.pdf last-1 ...] --suffix [reversed]
copy

SYNOPSIS

pdfjam [options] [PDF input files]

PARAMETERS

--nup
    Arrange pages into an nxm grid on each output page.

--landscape
    Rotate pages to landscape orientation before arrangement.

--booklet
    Arrange pages for booklet printing.

--scale
    Scale pages by a factor of .

--offset
    Offset pages by specified x and y values.

--rotate
    Rotate pages by degrees (0, 90, 180, 270).

--pdftitle
    Set the title of the output PDF.

--pdfauthor
    Set the author of the output PDF.

--paper
    Set the paper size of the output PDF (e.g., letter, a4).

--outfile
    Specify the output filename.

--trim <'left bottom right top'>
    Trim borders from input pages.


    One or more PDF files to be processed.

DESCRIPTION

pdfjam is a versatile command-line tool for manipulating PDF files. It is essentially a shell script wrapper around the pdfpages LaTeX package, simplifying common PDF manipulation tasks. pdfjam allows users to perform operations such as joining (n-up), splitting, rotating, and selecting pages from one or more PDF files. It's particularly useful for creating booklets, posters, or any documents where specific page layouts are required.
It simplifies the process of working with PDF files in batch operations or within automated workflows. Instead of requiring extensive knowledge of LaTeX syntax, users can leverage pdfjam's intuitive command-line options to achieve the desired PDF modifications. It relies on LaTeX for PDF creation and manipulation, hence a working LaTeX installation is a prerequisite. pdfjam streamlines complex tasks into manageable command-line invocations making it a valuable tool for Linux system administrators and users alike.

CAVEATS

Requires a working LaTeX installation. The pdfpages LaTeX package needs to be installed to work correctly. Can be slow for very large PDF files. Error messages can be cryptic and sometimes hard to understand.

EXAMPLES

To join two PDF files into one, use:
pdfjam input1.pdf input2.pdf -o output.pdf
To create a booklet from a PDF, use:
pdfjam --booklet input.pdf -o booklet.pdf
To arrange 2x2 pages from input.pdf to output.pdf:
pdfjam --nup 2x2 input.pdf -o output.pdf

SEE ALSO

Copied to clipboard