pdfjoin
Merge multiple PDF files into one
TLDR
Merge two PDFs into one with the default suffix "joined"
Merge the first page of each given file together
Save pages 3 to 5 followed by page 1 to a new PDF with custom suffix
Merge page subranges from two PDFs
SYNOPSIS
pdfjoin [options] input_files...
PARAMETERS
-o outfile, --outfile outfile
Specifies the name of the output PDF file. If not provided, a default name like 'merged.pdf' or based on the first input file is used.
--rotatepages direction
Rotates all pages in the output PDF by a specified direction (e.g., 90, 180, 270, 'left', 'right', 'down').
--fitpaper
Adjusts the paper size of the output document to fit the size of the input pages. Useful for combining PDFs with different dimensions.
--keepinfo
Attempts to preserve PDF information such as forms, links, and outlines. Note that LaTeX re-rendering might still affect some properties.
--paper size, --papersize size
Sets the paper size for the output document (e.g., 'a4paper', 'letterpaper', 'a3', 'a5').
--landscape, --portrait
Forces the output document's orientation to landscape or portrait, overriding default page orientations.
--nup num
Arranges num input pages onto a single output page (N-up imposition). For example, '--nup 2x1' puts two pages side-by-side.
--suffix suffix, --prefix prefix
Adds a suffix or prefix to the output filename when processing multiple input files or if '--batch' is used.
--parms parameters
Passes additional parameters directly to the underlying pdfpages LaTeX package. This offers fine-grained control.
--verbose, -v
Displays more detailed information during processing.
--quiet, -q
Suppresses most output messages.
--version
Displays the version information of pdfjoin.
--help
Displays a help message with command-line options.
DESCRIPTION
The pdfjoin command is a versatile utility for merging multiple PDF documents into a single output file. Unlike many PDF manipulation tools that directly operate on the PDF structure, pdfjoin leverages the powerful LaTeX typesetting system and its pdfpages package.
It works by generating a temporary LaTeX document that includes the specified input PDF files, then compiles this document using pdflatex to produce the final merged PDF. This approach allows for advanced features like selecting specific page ranges, rotating pages, scaling content, and even imposing multiple pages onto a single sheet (N-up printing).
While highly flexible, its reliance on LaTeX means that a full TeX distribution must be installed on the system, and the processing can be slower for very large files or complex operations compared to tools that parse PDF directly.
CAVEATS
pdfjoin relies heavily on a working LaTeX installation, specifically the pdflatex compiler and the pdfpages package. Without these, the command will not function. Due to the LaTeX compilation process, it can be significantly slower and more resource-intensive than direct PDF manipulation tools. It may also re-render pages, potentially altering or flattening interactive forms, annotations, and internal/external links, although the --keepinfo option tries to mitigate this. It is generally best suited for merging or re-arranging pages rather than complex PDF editing tasks.
UNDERLYING TECHNOLOGY
At its core, pdfjoin is a shell script that dynamically generates a .tex file containing LaTeX commands (primarily using the pdfpages package) to include and arrange the input PDFs. This .tex file is then compiled using pdflatex to produce the final merged PDF. This indirect approach provides immense flexibility for page manipulation but necessitates a full TeX environment.
INSTALLATION
pdfjoin is usually installed as part of a TeX Live distribution. On Debian/Ubuntu-based systems, it's typically found in the texlive-extra-utils package (or similar, depending on the distribution). Users need to ensure they have the full TeX environment set up for pdfjoin to function correctly.
HISTORY
pdfjoin is a wrapper script that simplifies the use of the pdfpages LaTeX package for command-line PDF merging. It was developed to provide a convenient front-end for users who might not be familiar with LaTeX syntax but want to leverage the powerful PDF capabilities of pdfpages. It is typically distributed as part of the texlive-extra-utils package within the broader TeX Live distribution, evolving alongside the pdfpages package itself.