Skip to main content

Watermark PDFs

Adds a watermark behind the content of each page of one or more PDF files. Use text for a simple label, image to tile an uploaded image, or pdf to place a full-page PDF underneath.

The watermarkOptions form field accepts a JSON object whose keys depend on the configured PDF Engine:

EngineSyntax Reference
pdfcpu (Default)See pdfcpu watermark documentation
pdftkSee pdftk documentation

Available keys include font, points (font size), color, rotation, opacity, scale, offset, and more. Example:

{
"font": "Helvetica",
"points": 48,
"color": "#808080",
"rotation": 45,
"opacity": 0.15
}

Check the PDF Engines Configuration to see which engine is active.

POST/forms/pdfengines/watermark
Headers
Gotenberg-Output-Filenamestring
The filename of the resulting file - Gotenberg automatically appends the file extension. Defaults to a random UUID filename.
Gotenberg-Tracestring
A custom request ID to identify the request in the logs; overrides the default UUID.
Form Fields
watermarkSourceenumrequired
The watermark source type. Options: 'text', 'image', 'pdf'.
watermarkExpressionstringrequired
The watermark content. For 'text', the string to render. For 'image' or 'pdf', the filename of the uploaded watermark file.
watermarkPagesstring
Page ranges to watermark (e.g., '1-3', '5'). Empty means all pages.
watermarkOptionsjson
Advanced options in JSON format (e.g., font, color, rotation, opacity, scaling).
Form Files
filesfile[]required
PDF files to watermark.
watermarkfile
An image or PDF file used as watermark source (required when watermarkSource is 'image' or 'pdf').
cURL
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.pdf
The watermarked PDF file.
Content-Disposition: attachment; filename={output-filename.pdf}
Content-Type: {content-type}
Content-Length: {content-length}
Gotenberg-Trace: {trace}
Body: {output-file}
SponsorsTCMpdfme
Powered byDockerJetBrains