Overview of Gotenberg PDF API
multipart/form-data to receive a PDF. Supported operations include conversion, merging, splitting, encrypting, watermarking, metadata management, and Factur-X / ZUGFeRD e-invoicing.website·Indexed 35 days ago
https://gotenberg.dev/docsA Docker-based API for converting documents to PDF and manipulating PDF files. It provides modules for Headless Chromium and LibreOffice to convert HTML, Markdown, and various document formats to PDF, as well as tools to merge, split, rotate, watermark, encrypt, and optimize PDFs.
multipart/form-data to receive a PDF. Supported operations include conversion, merging, splitting, encrypting, watermarking, metadata management, and Factur-X / ZUGFeRD e-invoicing.downloadFrom fetches, and LibreOffice fetches for document references. By default, Gotenberg is permissive, assuming it runs within a trusted network behind an API gateway. All outbound requests pass through a pipeline consisting of allow/deny regex filters, IP-class checks, and a DNS-rebind pinning proxy./forms/pdfengines/merge endpoint to combine multiple PDF files. Files are merged in alphanumeric order (numbers first, then alphabetical). Since version 8.37.0, files sharing the same filename are all preserved and merged in the order they were uploaded.curl \
--request POST http://localhost:3000/forms/pdfengines/merge \
--form files=@/path/to/1_pdf.pdf \
--form files=@/path/to/2_pdf.pdf \
--form files=@/path/to/3_pdf.pdf \
-o my.pdfGotenberg provides two ways to handle accessibility and archival standards:
generateTaggedPdf=true to embed a logical structure tree (headings, paragraphs). This is faster and preferred for screen readers.pdfa (PDF/A-1b, PDF/A-2b, PDF/A-3b) or pdfua=true. This is a slower second pass.Caveats:
# Native Chromium Accessibility
curl \
--request POST http://localhost:3000/forms/chromium/convert/html \
--form files=@/path/to/index.html \
--form generateTaggedPdf=true \
-o my.pdf
# Post-Processing PDF/A and PDF/UA
curl \
--request POST http://localhost:3000/forms/chromium/convert/html \
--form files=@/path/to/index.html \
--form pdfa=PDF/A-1b \
--form pdfua=true \
-o my.pdfAttach files directly inside the PDF container using the embeds form files. To satisfy PDF/A-3 or Factur-X requirements, use embedsMetadata to specify the mimeType and relationship (e.g., Source, Data, Alternative, Supplement) for each file, keyed by the filename.
This feature requires a supported PDF engine (QPDF is the default).
curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--form url=https://my.url \
--form embeds=@factur-x.xml \
--form embeds=@logo.png \
--form embedsMetadata='{"factur-x.xml":{"mimeType":"text/xml","relationship":"Alternative"},"logo.png":{"mimeType":"image/png","relationship":"Supplement"}}' \
-o my.pdfImportant constraints for high-fidelity rendering:
Dockerfile.file:// paths or external URLs) for security. The conversion will succeed (200 OK), but the linked content will be absent. Use embedded images instead of linked images..docm, .xlsm) are disabled by default; macro-generated content will not execute./forms/pdfengines/watermark endpoint to add a watermark behind the content of each page of one or more PDF files. You can use a simple text label, a tiled image, or a full-page PDF as the watermark source. If multiple input files are provided, Gotenberg returns a ZIP archive of the watermarked PDFs.curl \
--request POST http://localhost:3000/forms/pdfengines/watermark \
--form files=@/path/to/file.pdf \
--form watermarkSource=text \
--form watermarkExpression=CONFIDENTIAL \
--form 'watermarkOptions={"opacity":0.25,"rotation":45}' \
-o my.pdfembedsMetadata to specify the MIME type and the relationship of the file to the document.curl \
--request POST http://localhost:3000/forms/chromium/convert/markdown \
--form files=@/path/to/index.html \
--form files=@/path/to/file.md \
--form embeds=@factur-x.xml \
--form embeds=@logo.png \
--form embedsMetadata='{"factur-x.xml":{"mimeType":"text/xml","relationship":"Alternative"},"logo.png":{"mimeType":"image/png","relationship":"Supplement"}}' \
-o my.pdfLayout shifts in LibreOffice usually occur when the container lacks the fonts used in the document, causing LibreOffice to use substitutes.
ttf-mscorefonts-installer.exportFormFields=false to flatten the fields.Set passwords and permissions to control PDF access.
userPassword: Required to open the PDF.ownerPassword: Grants full access and lifts restrictions. If empty, it defaults to the user password.allowPrinting, allowCopying, allowModifying, allowAnnotating, allowFillingForms, and allowAssembling (all default to true).Constraints:
userPassword or ownerPassword (otherwise returns 400 Bad Request).curl \
--request POST http://localhost:3000/forms/chromium/convert/html \
--form files=@/path/to/index.html \
--form userPassword=my_user_password \
--form ownerPassword=my_owner_password \
--form allowCopying=false \
-o my.pdfcurl \
--request POST http://localhost:3000/forms/pdfengines/merge \
--form files=@/path/to/1_pdf.pdf \
--form files=@/path/to/2_pdf.pdf \
--form userPassword=my_user_password \
--form ownerPassword=my_owner_password \
--form allowCopying=false \
-o my.pdf