github pdfcpu/pdfcpu v0.4.0

latest releases: v0.8.0, v0.7.0, v0.6.0...
14 months ago

Hello, the main focus of this release is PDF form management!

This release has been a long time coming 😓 Thank you 🙏 for your patience!


API-Users, please proceed with caution!
The codebase has been refactored heavily and there may be some side effects.

E.g. usages of: api.Merge(rsc []io.ReadSeeker,...) need to be migrated to api.MergeRaw(rsc []io.ReadSeeker, ...)


pdfcpu v0.4.0 is now based on go1.20 and comes with two new commands:

  1. The new powerful formcommand solves all major form handling usecases:
pdfcpu form list   inFile...
pdfcpu form remove inFile [outFile] fieldID...
pdfcpu form lock   inFile [outFile] [fieldID...]
pdfcpu form unlock inFile [outFile] [fieldID...]
pdfcpu form reset  inFile [outFile] [fieldID...]
pdfcpu form export inFile [outFileJSON]
pdfcpu form fill inFile inFileJSON [outFile]
pdfcpu form multifill [-m(ode) single|merge] inFile inFileData outDir [outName]

DISCLAIMER 1
You are free to export and fill already existing PDF forms - this may or may not work!
Feel free to open an issue and we may be able to make it work.


DISCLAIMER 2
All forms generated with pdfcpu create are optimized for Adobe Reader.
Mac Preview is not suited well for form handling!


The following workflows are supported:

The Regular Workflow

  • Create your form with the already introduced create command.
  • Print a list of your form fields on the command line.
  • export your form to JSON,
  • Edit your JSON and enter your form data.
  • fill your form with this JSON payload.
  • Optionally write protect individual fields using lock.

The Fill & Merge Workflow

"Give me access to your contacts db and I will generate a single PDF containing a page sequence of contact sheets"

This usecase is implemented by extending the regular workflow by an additional integrated merge step.

As for automatically filling a form with your data pdfcpu gives you two options:

  • JSON - better suited for API providers, verbose but powerful JSON elements, allows full fledged imageBoxes for image fields
  • CSV - for on-premises bulk fill scenarios, one CSV line representing a form instance, has its limitations eg. need to fake image fields

  1. The new resize command comes to the rescue when you're stuck with some large pages in front of a regular small form printer:
pdfcpu resize [-p(ages) selectedPages] -- [description] inFile [outFile]

Scale your pages up or down or resize to one of the many supported standard form sizes (pdfcpu paper prints a list ) optionally enforcing portrait or landscape mode:

Examples:

         pdfcpu resize "scale:2" in.pdf out.pdf
            Enlarge pages by doubling the page dimensions, keep orientation.

         pdfcpu resize -pages 1-3 -- "sc:.5" in.pdf out.pdf
            Shrink first 3 pages by cutting in half the page dimensions, keep orientation.

         pdfcpu resize -u cm -- "dim:40 0" in.pdf out.pdf
            Resize pages to width of 40 cm, keep orientation.

         pdfcpu resize "form:A4" in.pdf out.pdf
            Resize pages to A4, keep orientation.

         pdfcpu resize "f:A4P, bgcol:#d0d0d0" in.pdf out.pdf
            Resize pages to A4 and enforce orientation(here: portrait mode), apply background color.

         pdfcpu resize "dim:400 200" in.pdf out.pdf
            Resize pages to 400 x 200 points, keep orientation.

         pdfcpu resize "dim:400 200, enforce:true" in.pdf out.pdf
            Resize pages to 400 x 200 points, enforce orientation.

Countless bugs have been rolling in and many of those have been fixed. Thank you 🙏 all also for your PRs 👍 💚
Unfortunately due to heavy refactoring of the code base some of them had to be merged in manually or still will be.

Changelog

Don't miss a new pdfcpu release

NewReleases is sending notifications on new releases.