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
| Option | Default | Description |
|---|
-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
PDFSplit
The split command reads a single PDF and writes multiple output files. Without a page range, it splits every page into its own file (one page per PDF). Use -split to set a fixed page count per chunk, or -startPage/-endPage to extract a contiguous range into a single output file.Usage
java -jar pdfbox-app-3.0.0.jar split -i <input.pdf> [options]
Options
| Option | Default | Description |
|---|
-i, --input | (required) | Path to the input PDF file |
-password | (none) | Password to decrypt the document |
-split | 1 | Split after every N pages (default 1 when neither -startPage nor -endPage is set) |
-startPage | (none) | First page of the range to extract (1-based) |
-endPage | (none) | Last page of the range to extract (1-based, inclusive) |
-outputPrefix | (auto) | Filename prefix for output files; defaults to the input path without extension |
Output files are named <prefix>-1.pdf, <prefix>-2.pdf, and so on.Examples
Split every page into its own file:java -jar pdfbox-app-3.0.0.jar split -i book.pdf
# writes: book-1.pdf, book-2.pdf, ...
Split into chunks of 10 pages each:java -jar pdfbox-app-3.0.0.jar split -i book.pdf -split 10
Extract pages 5 through 12 into a single file:java -jar pdfbox-app-3.0.0.jar split -i book.pdf \
-startPage 5 -endPage 12 -outputPrefix chapter2
# writes: chapter2-1.pdf