
PDF tooling for Go and the command line.
View the Project on GitHub pdfcpu/pdfcpu
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.
pdfcpu trim inFile [outFile] [flags]
| name | description | required |
|---|---|---|
| p(ages) | selected pages | yes |
| name | description | required | default |
|---|---|---|---|
| inFile | PDF input file, use - to read from stdin | yes | |
| outFile | PDF output file, use - to write to stdout | no | inFile |
The following PDF elements are not carried over into the trimmed document:
Get rid of unwanted blank pages:
$ pdfcpu trim --pages even test.pdf test_trimmed.pdf
$ pdfcpu trim -p 1 test.pdf firstPage.pdf
$ 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