pdfcpu

Logo

PDF tooling for Go and the command line.

View the Project on GitHub pdfcpu/pdfcpu


Changelog
Future Directions

Trim

Generate a new PDF containing only the selected pages of inFile.

trim removes pages from the document by page selection. It does not crop page content, change page boxes, or remove white margins on a page. Use crop for changing the visible page area.

The output keeps the selected pages in their original order and writes them to outFile. If outFile is omitted, inFile is overwritten.

Have a look at some examples.

Usage

pdfcpu trim inFile [outFile] [flags]

Flags

namedescriptionrequired
p(ages)selected pagesyes

Common Flags


Arguments

namedescriptionrequireddefault
inFilePDF input file, use - to read from stdinyes
outFilePDF output file, use - to write to stdoutnoinFile

Restrictions

The following PDF elements are not carried over into the trimmed document:


Examples

Get rid of unwanted blank pages:

$ pdfcpu trim --pages even test.pdf test_trimmed.pdf

Create a single page PDF file for a specific page number:
$ pdfcpu trim -p 1 test.pdf firstPage.pdf

Get rid of the catalog and trailing index:
$ pdfcpu trim book.pdf essence.pdf --pages '!2-4,!12-'

Trim a streamed PDF and upload the result:

$ aws s3 cp s3://acme-cases/filing.pdf - \
   | pdfcpu trim --pages 1-12 - - \
   | aws s3 cp - s3://acme-cases/filing-trimmed.pdf