Back to Pdfcpu

pdfcpu: a PDF processor written in Go with CLI and API support

README.md

1.0.0-test17.7 KB
Original Source

pdfcpu: a PDF processor written in Go with CLI and API support

<p align="left"> <a href="https://pdfcpu.io"></a> <a href="https://pdfa.org"></a> </p>

pdfcpu is a PDF processing library written in Go.

It is compatible with all PDF versions. Support for PDF 2.0 (ISO-32000-2) is evolving and continuously improving.


Installation

CLI

Prebuilt binaries and installation instructions (Homebrew, Docker, packages):

Installation instructions

Go API

Install pdfcpu as a Go module:

go get github.com/pdfcpu/pdfcpu

API documentation:

Installation and usage


Usage

CLI

Validate against PDF 2.0 (ISO-32000-2):

pdfcpu validate input.pdf

Merge two PDFs:

pdfcpu merge out.pdf in1.pdf in2.pdf

Go API

See API documentation for usage examples.


Features

  • Validate, optimize, split, trim, and merge PDFs
  • Extract and manipulate images, fonts, and metadata
  • Encrypt and decrypt PDFs
  • Resize and rotate pages
  • Add and remove stamps and watermarks
  • Manage digital signatures (ongoing work)
  • Manage attachments and more...

In Action

Common operations and examples:

<p align="center"> <kbd><a href="https://pdfcpu.io/generate/grid"></a></kbd>&nbsp; <kbd><a href="https://pdfcpu.io/core/watermark"></a></kbd>&nbsp; <kbd><a href="https://pdfcpu.io/generate/nup"></a></kbd>&nbsp; <kbd><a href="https://pdfcpu.io/fonts/fonts"></a></kbd>&nbsp; <kbd><a href="https://pdfcpu.io/core/stamp"></a></kbd>&nbsp; <kbd><a href="https://pdfcpu.io/form/form"></a></kbd>

<kbd><a href="https://pdfcpu.io/generate/create"></a></kbd>  <kbd><a href="https://pdfcpu.io/core/stamp"></a></kbd>  <kbd></kbd>  <kbd><a href="https://pdfcpu.io/core/watermark"></a></kbd>  <kbd><a href="https://pdfcpu.io/generate/create"></a></kbd> 

<kbd><a href="https://pdfcpu.io/generate/booklet"></a></kbd> <kbd><a href="https://pdfcpu.io/core/stamp"></a></kbd>  <kbd><a href="https://pdfcpu.io/generate/grid"></a></kbd> <kbd><a href="https://pdfcpu.io/core/stamp"></a></kbd> <kbd><a href="https://pdfcpu.io/generate/booklet"></a></kbd>

</p>

Command Set

Complete list of supported commands:

annotationsattachmentsbooklet
bookmarksboxescertificates
change owner passwordchange user passwordcollect
configcreatecrop
cutdecryptencrypt
extractfontsform
gridimagesimport
infokeywordsmerge
ndownnupoptimize
pagelayoutpagemodepages
permissionsportfolioposter
propertiesresizerotate
signaturessplitstamp
trimvalidateviewerpref
watermarkzoom

Motivation

pdfcpu aims to provide comprehensive PDF processing capabilities implemented in Go.

It focuses on correctness, robustness and independence from external dependencies.


Focus

  • comprehensive PDF processing functionality
  • minimal external dependencies
  • predictable and stable behavior

Documentation

CLI

  • Command help: pdfcpu [command] --help

Go API


Contributing

Contributions are welcome.

  • Report bugs or propose changes via issues
  • Discuss ideas on the discussion board
  • For PRs, please open an issue or discussion first v

Guidelines

  • Base your work on the latest commit
  • Include verbose output (pdfcpu cmd -vv ...) and a sample PDF when reporting issues
  • Please sign your commits

Reporting crashes

Crashes may occur due to the wide variety of PDF producers and formats in use, including older or non-compliant files. In many cases this is related to validation issues or edge cases in the parser.

Even with relaxed validation, some files cannot be processed. These cases are essential for improving pdfcpu by extending validation and handling additional real-world PDFs.

If you encounter a crash, please report it.

Start by validating the file using the CLI:

bash
pdfcpu validate -vv <file.pdf>

Include in your report:

  • the command used
  • verbose output (-vv)
  • a sample PDF (if possible)

If validation crashes for a PDF that opens in Adobe Reader or macOS Preview, it is likely we can extend relaxed validation and provide a fix.

If the file cannot be opened by both Adobe Reader and macOS Preview, we cannot support it.

Please include a sample PDF to reproduce the issue whenever possible.


Contributors

Thanks 💚 to all contributors:

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
[
<sub><b>Horst Rutter</b></sub>](https://github.com/hhrutter)[
<sub><b>haldyr</b></sub>](https://github.com/haldyr)[
<sub><b>Vyacheslav</b></sub>](https://github.com/SimePel)[
<sub><b>Erik Unger</b></sub>](https://github.com/ungerik)[
<sub><b>Richard Wilkes</b></sub>](https://github.com/richardwilkes)[
<sub><b>minenok-tutu</b></sub>](https://github.com/minenok-tutu)[
<sub><b>Mateusz Burniak</b></sub>](https://github.com/matbur)
[
<sub><b>Dmitry Harnitski</b></sub>](https://github.com/dharnitski)[
<sub><b>ryarnyah</b></sub>](https://github.com/ryarnyah)[
<sub><b>Sam Giffney</b></sub>](https://github.com/s01ipsist)[
<sub><b>Carlos Eduardo Witte</b></sub>](https://github.com/cewitte)[
<sub><b>minusworld</b></sub>](https://github.com/minusworld)[
<sub><b>Witold Konior</b></sub>](https://github.com/jozuenoon)[
<sub><b>joonas.fi</b></sub>](https://github.com/joonas-fi)
[
<sub><b>Henrik Reinstädtler</b></sub>](https://github.com/henrixapp)[
<sub><b>VMorozov-wh</b></sub>](https://github.com/VMorozov-wh)[
<sub><b>Benoit KUGLER</b></sub>](https://github.com/benoitkugler)[
<sub><b>Adam Greenhall</b></sub>](https://github.com/adamgreenhall)[
<sub><b>moritamori</b></sub>](https://github.com/moritamori)[
<sub><b>JanBaryla</b></sub>](https://github.com/JanBaryla)[
<sub><b>TheDiscordian</b></sub>](https://github.com/TheDiscordian)
[
<sub><b>Rafael Garcia Argente</b></sub>](https://github.com/rgargente)[
<sub><b>truyet</b></sub>](https://github.com/truyet)[
<sub><b>Christian Nicola</b></sub>](https://github.com/christiannicola)[
<sub><b>Benjamin Krill</b></sub>](https://github.com/kben)[
<sub><b>Peter Wyatt</b></sub>](https://github.com/petervwyatt)[
<sub><b>Kroum Tzanev</b></sub>](https://github.com/kpym)[
<sub><b>Stefan Huber</b></sub>](https://github.com/signalwerk)
[
<sub><b>Juan Iscar</b></sub>](https://github.com/juaismar)[
<sub><b>Eng Zer Jun</b></sub>](https://github.com/Juneezee)[
<sub><b>Dmitry Ivanov</b></sub>](https://github.com/hant0508)[
<sub><b>Rene Kaufmann</b></sub>](https://github.com/HeavyHorst)[
<sub><b>Christian Heusel</b></sub>](https://github.com/christian-heusel)[
<sub><b>Chris</b></sub>](https://github.com/freshteapot)[
<sub><b>Lukasz Czaplinski</b></sub>](https://github.com/scoiatael)
[
<sub><b>Joel Silva Schutz</b></sub>](https://github.com/joelschutz)[
<sub><b>semvis123</b></sub>](https://github.com/semvis123)[
<sub><b>guangwu</b></sub>](https://github.com/testwill)[
<sub><b>Yoshiki Nakagawa</b></sub>](https://github.com/yyoshiki41)[
<sub><b>Steve van Loben Sels</b></sub>](https://github.com/stevevls)[
<sub><b>Yaofu</b></sub>](https://github.com/mygityf)[
<sub><b>vsenko</b></sub>](https://github.com/vsenko)
[
<sub><b>Alexis Hildebrandt</b></sub>](https://github.com/afh)[
<sub><b>Sivukhin Nikita</b></sub>](https://github.com/sivukhin)[
<sub><b>Joachim Bauch</b></sub>](https://github.com/fancycode)[
<sub><b>kalimit</b></sub>](https://github.com/kalimit)[
<sub><b>Andreas Erhard</b></sub>](https://github.com/xelan)[
<sub><b>Matsumoto Toshi</b></sub>](https://github.com/toshi1127)[
<sub><b>Carl Wilson</b></sub>](https://github.com/carlwilson)
[
<sub><b>LNAhri</b></sub>](https://github.com/LNAhri)[
<sub><b>vishal</b></sub>](https://github.com/vishal-at)[
<sub><b>Andreas Deininger</b></sub>](https://github.com/deining)[
<sub><b>Robert Raines</b></sub>](https://github.com/solintllc-robert)[
<sub><b>Frank Anderson</b></sub>](https://github.com/frob)[
<sub><b>Sven Lilienthal</b></sub>](https://github.com/SveLil)[
<sub><b>Florian Kinder</b></sub>](https://github.com/fank)
[
<sub><b>mdmcconnell</b></sub>](https://github.com/mdmcconnell)[
<sub><b>Bradley Erickson</b></sub>](https://github.com/13rac1)[
<sub><b>doronbehar</b></sub>](https://github.com/doronbehar)[
<sub><b>joeyave</b></sub>](https://github.com/joeyave)
<!-- ALL-CONTRIBUTORS-LIST:END - Do not remove or modify this section -->

Code of Conduct

This project is released with a Contributor Code of Conduct. By participating, you agree to abide by its terms.


Disclaimer

Use of pdfcpu assumes compliance with all applicable copyrights for any processed PDF content, including embedded resources such as fonts and images.

Gopher artwork by Renee French


License

Apache License 2.0