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.
See the PDF Engines module configuration for engine selection flags.
The watermarkOptions form field accepts a JSON object whose keys depend on the configured PDF engine:
| Engine | Syntax Reference |
|---|---|
| pdfcpu (Default) | See pdfcpu watermark documentation |
| pdftk | See 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 module configuration to see which engine is active.
Basics
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
- 200
- 400
- 503
Content-Disposition: attachment; filename={output-filename.ext}
Content-Type: {content-type}
Content-Length: {content-length}
Gotenberg-Trace: {trace}
Body: {output-file}
Content-Type: text/plain; charset=UTF-8
Gotenberg-Trace: {trace}
Body: {error}
Content-Type: text/plain; charset=UTF-8
Gotenberg-Trace: {trace}
Body: {error}
Multiple Watermarks
Repeat the watermark form fields to apply several watermarks in one request. Gotenberg reads watermarkSource, watermarkExpression, watermarkPages, and watermarkOptions as parallel lists and applies each watermark in order. A single occurrence of each field is the single-watermark case above.
Each image or pdf watermark consumes the uploaded watermark files in order; text watermarks take none.
curl \
--request POST http://localhost:3000/forms/pdfengines/watermark \
--form files=@/path/to/file.pdf \
--form watermarkSource=text --form watermarkExpression=DRAFT \
--form watermarkSource=image --form watermark=@/path/to/logo.png \
-o my.pdf
What's Next?
Overlay text or images with Stamp, or fix page orientation with Rotate.