Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/apache/pdfbox/llms.txt

Use this file to discover all available pages before exploring further.

PDFBox provides two complementary tools for restructuring PDF documents: merge combines an ordered list of PDFs into a single output file, and split divides a PDF into multiple output files at configurable page boundaries. Both tools preserve page content faithfully and write standard PDF output.

PDFMerger

The merge command accepts two or more input PDFs and concatenates them in the order given, writing the result to a single output file. Bookmarks, annotations, and page content from each source document are preserved.

Usage

java -jar pdfbox-app-3.0.0.jar merge -i <file1.pdf> -i <file2.pdf> ... -o <output.pdf>

Options

OptionDefaultDescription
-i, --input(required)Input PDF file; repeat the flag for each source
-o, --output(required)Path for the merged output PDF

Examples

Merge two PDFs into one:
java -jar pdfbox-app-3.0.0.jar merge \
  -i chapter1.pdf -i chapter2.pdf \
  -o combined.pdf
Merge four files and write the result to a specific directory:
java -jar pdfbox-app-3.0.0.jar merge \
  -i q1.pdf -i q2.pdf -i q3.pdf -i q4.pdf \
  -o /reports/annual.pdf

Build docs developers (and LLMs) love