The Coherent PDF Command Line Tools allow you to manipulate existing PDF files in a variety of ways. For example:
- Merge PDF files together, or split them apart
- Encrypt and decrypt
- Scale, crop and rotate pages
- Read and set document info and metadata
- Copy, add or remove bookmarks
- Stamp logos, text, dates, page numbers
- Add or remove attachments
cpdf tool has been available commercially since 2007, and is widely used in industry and government. The same technology is used in the Proview PDF Editor for the mac.
Also included is the Coherent Lossless PDF Compressor,
smpdf, which reduces the size of PDF files by rearranging their internal structure.
Now we're releasing them for free, under a special not-for-commercial-use license If you like the tools and want to use them commercially, or need support, licenses are available from Coherent Graphics Ltd. If you're still not sure if you need a license, ask us.
Download binaries now for Windows, Mac, or Linux
Pre-built binaries are available for Windows, Mac OS 10.6 and later, Linux 32 bit Intel and Linux 64 bit intel.
Build from source
In all cases, on Microsoft Windows, substitute
Select some pages from a file
in.pdf and write to
cpdf in.pdf 1-3,12-end -o out.pdf
Merge some files together:
cpdf one.pdf two.pdf three.pdf -o merged.pdf
Split a file into single-page files
cpdf -split in.pdf -o page%%%.pdf
Encrypt a file with 128 bit AES encryption with an owner password but blank user password:
cpdf -encrypt AES "pass" "" in.pdf -o out.pdf
Output some information about a file:
cpdf -info file.pdf Encryption: Not encrypted Permissions: Linearized: true Version: 1.4 Pages: 8 Title: catalogueproduit-UK.qxd Author: James Peterson Subject: Keywords: Creator: QuarkXPress: pictwpstops filter 1.0 Producer: Acrobat Distiller 6.0 for Macintosh Created: D:20060926213913+02'00' Modified: D:20060926213913+02'00'
Output information about each page:
cpdf -page-info file.pdf Page 1: MediaBox: 0.000000 0.000000 768.000000 1366.000000 CropBox: BleedBox: 0.000000 0.000000 768.000000 1366.000000 TrimBox: 0.000000 0.000000 768.000000 1366.000000 ArtBox: 0.000000 0.000000 768.000000 1366.000000 Rotation: 0 Page 2: MediaBox: 0.000000 0.000000 768.000000 1366.000000 CropBox: BleedBox: 0.000000 0.000000 768.000000 1366.000000 TrimBox: 0.000000 0.000000 768.000000 1366.000000 ArtBox: 0.000000 0.000000 768.000000 1366.000000 Rotation: 0
Scale pages to A4 paper:
cpdf -scale-to-fit a4portrait in.pdf -o out.pdf
Crop a file:
cpdf -crop "20mm 20mm 300mm 300mm" in.pdf -o out.pdf
Add some text with page numbers:
cpdf -add-text "Page %Page of %EndPage" -top 100pt -font "Times-Roman" -font-size 20 in.pdf -o out.pdf
Stamp one PDF file over each page of another:
cpdf -stamp-on logo.pdf in.pdf -o out.pdf
Attach a file to page 5:
cpdf -attach-file sheet.xls -to-page 5 in.pdf -o out.pdf
Combine several commands together using AND: flip a file vertically and stamp text, then encrypt.
cpdf in.pdf -vflip AND -add-text "Page %Page" AND -encrypt 128bit owner "" -o out.pdf
Compress a file without loss of information:
smpdf in.pdf -o out.pdf
Please note, though, that we prioritise support for paying customers.
Q. The cpdf program prints a message about its non-commercial status every time I run it. How can I stop that?
A. The message is printed to standard error, so if you're using
cpdf in an automated system, you can just redirect standard error to null. On Linux and OS X this is done by adding
2>/dev/null to the end of the command. On Windows, use
Q. My command works, but fails when I put it in a Windows Batch file.
cpdf commands use
% as a special character. Use