LinuxCommandLibrary

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

$ cpdf [path/to/source_document.pdf] [1-3,6] -o [path/to/destination_document.pdf]
copy

Merge two documents into a new one
$ cpdf -merge [path/to/source_document_one.pdf] [path/to/source_document_two.pdf] -o [path/to/destination_document.pdf]
copy

Show the bookmarks of a document
$ cpdf -list-bookmarks [path/to/document.pdf]
copy

Split a document into ten-page chunks, writing them to chunk001.pdf, chunk002.pdf, etc
$ cpdf -split [path/to/document.pdf] -o [path/to/chunk%%%.pdf] -chunk [10]
copy

Encrypt a document using 128bit encryption, providing fred as owner password and joe as user password
$ cpdf -encrypt [128bit] [fred] [joe] [path/to/source_document.pdf] -o [path/to/encrypted_document.pdf]
copy

Decrypt a document using the owner password fred
$ cpdf -decrypt [path/to/encrypted_document.pdf] owner=[fred] -o [path/to/decrypted_document.pdf]
copy

Show the annotations of a document
$ cpdf -list-annotations [path/to/document.pdf]
copy

Create a new document from an existing one with additional metadata
$ cpdf -set-metadata [path/to/metadata.xml] [path/to/source_document.pdf] -o [path/to/destination_document.pdf]
copy

SYNOPSIS

cpdf [options] input.pdf [pages] [operator] [output.pdf]
cpdf -merge file1.pdf file2.pdf -o output.pdf
cpdf -split input.pdf -o page%d.pdf
cpdf -encrypt input.pdf -owner-pwd ownerpass -user-pwd userpass -o encrypted.pdf

PARAMETERS

-merge
    Merges multiple PDF files or pages into a single output PDF.

-split
    Splits a PDF file into individual pages or specified page ranges.

-encrypt
    Encrypes a PDF with user and/or owner passwords, setting permissions for printing, copying, etc.

-decrypt
    Decrypts an encrypted PDF, requiring the correct password.

-rotate degrees
    Rotates specified pages by a given angle (e.g., 90, 180, 270).

-scale factor
    Scales page content by a specified factor (e.g., 0.5 for half size, 2 for double).

-add-text "text"
    Adds text content to specified pages at a given position and with specified formatting.

-add-image image.png
    Adds an image (e.g., PNG, JPEG) to specified pages.

-remove-pages pages
    Removes specified pages or page ranges from a PDF.

-compress
    Compresses the PDF to reduce file size, typically by optimizing streams and removing redundant data.

-decompress
    Decompresses streams within a PDF, which can aid in debugging or advanced editing.

-stamp stamp.pdf
    Overlays another PDF (stamp) onto the target PDF's pages, often used for watermarking or adding headers/footers.

-impose N-up
    Arranges multiple logical pages onto a single physical page (e.g., 2-up, 4-up for printing brochures).

-o output.pdf
    Specifies the output file name for the operation.

-verbose
    Provides more detailed output during execution, useful for debugging.

-version
    Displays the current version of cpdf.

DESCRIPTION

cpdf is a high-performance command-line utility for manipulating PDF files. Developed by Coherent PDF, it offers a wide range of functionalities including merging, splitting, encrypting, decrypting, rotating, scaling, watermarking, stamping, and text/image insertion.
Unlike some other PDF tools, cpdf is designed for speed and reliability, making it suitable for scripting, automation, and batch processing tasks. It can perform complex operations with simple commands, managing pages, metadata, and security settings with efficiency. Its comprehensive feature set makes it a go-to tool for developers and system administrators working with PDF documents in a Linux environment.

CAVEATS

cpdf is a commercial product, though a free version is typically available for non-commercial use on Linux distributions. Ensure you are using the appropriate license for your intended purpose.
While powerful, its extensive array of options can lead to a steep learning curve. It's not always pre-installed and might require manual installation depending on your distribution. Error messages can sometimes be terse, requiring careful command construction.

<I>LICENSING AND AVAILABILITY</I>

While often available in Linux repositories, it's important to note that the freely distributable version of cpdf is for non-commercial use only. For commercial applications, a paid license is required. This distinction is crucial for organizations deploying cpdf in production environments.

<I>PERFORMANCE</I>

cpdf is highly optimized for performance, making it exceptionally fast for large PDF files or batch operations. Its efficiency in handling complex PDF structures is a significant advantage over some other tools that might struggle with very large or intricate documents.

HISTORY

cpdf is developed by Coherent PDF, a company focused on PDF software solutions. It emerged as a high-performance, reliable command-line tool, distinguishing itself with its speed and comprehensive feature set compared to some open-source alternatives.
Its development has focused on providing robust capabilities for automated PDF processing, making it a favorite for server-side operations and complex scripting tasks. The tool has been consistently updated to support new PDF standards and functionalities.

SEE ALSO

qpdf(1), pdftk(1), pdfunite(1), gs(1), mupdf(1)

Copied to clipboard