cpdf
Manipulate and merge PDF files
TLDR
Select pages 1, 2, 3, and 6 from a source document and write those to a destination document
Merge two documents into a new one
Show the bookmarks of a document
Split a document into ten-page chunks, writing them to chunk001.pdf, chunk002.pdf, etc
Encrypt a document using 128bit encryption, providing fred as owner password and joe as user password
Decrypt a document using the owner password fred
Show the annotations of a document
Create a new document from an existing one with additional metadata
SYNOPSIS
cpdf [global-options] <input.pdf [<input2.pdf ...]> [operations ...] [-o <output.pdf> | -o <pattern>]
PARAMETERS
-version
Print version information
-help
Display help
-norc
Do not read resource file
-debug
Enable debug mode
-trace
Enable tracing
-v
Verbose output
-json
JSON output mode
-merge [-ntl | -ff | -fff]
Merge inputs (natural, file folder, file folder first)
-split <range>
Split by page range
-range <range-spec>
Select pages (e.g., 1-5,7,9-end)
-pages <n>
Select specific pages
-encrypt <userpass> <ownerpass> <options>
Encrypt PDF (40/128-bit, permissions)
-decrypt
Remove encryption
-rotate <range angle>
Rotate pages (90/180/270)
-upscale
Upscale pages to fill A4
-scale-to-fit <width height>
Scale pages to fit dimensions
-stamp-on <stamp.pdf> <range>
Stamp another PDF on pages
-impose <method>
Impose for booklet printing
-set-metadata <key value>
Set document metadata
-validate
Validate PDF structure
-fonts
List fonts in PDF
-info
Show PDF information
-box <boxname>
Set or list bounding boxes (MediaBox, CropBox etc.)
-add-text <text options>
Add text to pages
-compress
Compress images and streams
DESCRIPTION
cpdf is a versatile, high-performance command-line utility for processing PDF documents. Written in OCaml, it offers extensive operations including merging, splitting, rotating, scaling, encrypting, decrypting, watermarking, imposition, metadata editing, validation, and font embedding. It supports batch processing, range selection, and complex workflows via multiple operations per invocation. Unlike slower tools based on Ghostscript, cpdf is pure PDF and extremely fast, handling large files efficiently. Ideal for automation in scripts, it preserves PDF structure, fonts, and quality. Available in Linux distributions like Debian/Ubuntu via cpdf package. Outputs can be single files or ranges with patterns like out-%d.pdf. Supports JSON mode for integration.
CAVEATS
Some advanced features require paid license for >14 pages in Windows/Mac versions; Linux binary is free/unrestricted. Operations are sequential; order matters. No GUI.
BASIC EXAMPLES
Merge: cpdf in1.pdf in2.pdf -merge -o out.pdf
Split every 2 pages: cpdf in.pdf -split 2-2 -o out-%d.pdf
Rotate even pages: cpdf in.pdf -range even -rotate 90 -o out.pdf
RANGES
Syntax: 1-end, 3-5,7,odd,even. Use with most operations for page selection.
HISTORY
Developed by John Whitington since 2008 at Coherent Graphics. Evolved from PDFtk alternatives, focusing on speed and PDF1.7 compliance. Major versions: 2.x (2010s basics), 3.x (imposition), 4.x (JSON/web). Open-source components; binaries freely available.


