Skip to main content
A stage is one operation on a PDF: merge, stamp, sign, make PDF/A, and so on. Gotenberg runs the stages in the order you list them, each on what the previous one produced. Pass them as stages to: Screenshots don’t take stages. Each stage also has its own method on the PDF class, such as PDF.merge() or PDF.sign().
Every stage is a typed object discriminated by its op, with the option names Gotenberg documents. TypeScript checks each stage’s options.

Every stage

When several files come out, the answer is a ZIP: a split into several parts, or render and the extracts, which return their files next to the PDF.

Files a stage needs

An option that names a file takes a StageFile: insert.source, stamp-image.image, stamp-pdf.source, attach.file, remediate.xml, sign.certificate and sign.key. Chromiumly uploads it with the request and puts its name in the stage.
Two uploads under one name, such as an asset and a stage file, throw an error before the request is sent: reference the existing upload with { name }, or give one of them another name. compose is the exception: its placements[].source names one of the input PDFs, such as "report.pdf", rather than a file to upload.

Page selections

An option that takes pages, such as select.pages, accepts a comma-separated list of parts: odd,!1 keeps the odd pages after the first, and !last every page but the last. Without an inclusion, the selection starts from every page. Pages count from 1. A page past the end, or a selection that leaves no page, is refused with a 400.

Order rules

Gotenberg checks the order of the stages before it runs any, and refuses a list that breaks one of these rules with a 400 that names the rule:
  • decrypt comes first, and render, extract-attachments or extract-text last.
  • A list has at most one remediate, one encrypt, one sign and one timestamp. One remediate takes a PDF/A profile and a PDF/UA one together.
  • After remediate, only encrypt, optimize, sign, timestamp, render, extract-attachments and extract-text may follow.
  • After encrypt, only optimize, render, extract-attachments and extract-text may follow.
  • After sign or timestamp, only sign, timestamp, render, extract-attachments and extract-text may follow.
  • encrypt doesn’t combine with sign, timestamp, or a PDF/A or Factur-X remediate.
  • decrypt doesn’t combine with sign or timestamp: sign the decrypted PDF in a request of its own.
Some stages rewrite the PDF whole, which drops signatures, so they refuse a signed PDF: select, delete, insert, merge, split, compose, encrypt, decrypt, flatten-form, redact, remediate, convert-colors, flatten-transparency and optimize. The others append an update and keep signatures. See Reference — stages for every stage’s options.