endpoint
Watermark
POST /api/v1/watermark
Stamp a text or image watermark on any / all pages.
credits: 1returns: application/pdf
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| file | multipart file | required | Source PDF. |
| kind | "text" | "image" | required | Watermark type. |
| text | string | optional | Required when kind=text. |
| image | multipart file | optional | Required when kind=image. |
| position | enum | optional | corners, center, or "diagonal".default: center |
| opacity | float 0-1 | optional | Transparency.default: 0.35 |
| rotation | float (deg) | optional | Rotation.default: 0 |
| color | hex string | optional | Text color.default: #888888 |
| tile | boolean | optional | Repeat across the page. |
| pages | range spec | optional | Restrict to specific pages. |
Examples
curl
curl -X POST https://api.snappdf.au/api/v1/watermark \
-H "Authorization: Bearer $SNAPPDF_API_KEY" \
-F "file=@doc.pdf" -F "kind=text" -F "text=CONFIDENTIAL" \
-F "position=diagonal" -F "opacity=0.2" -F "color=#cc0000" \
-o stamped.pdfJavaScript
const { pdf } = await snap.pdf.watermark({ file: bytes, kind: 'text', text: 'CONFIDENTIAL', position: 'diagonal', opacity: 0.2 });Python
snap.pdf.watermark(file=bytes, kind="text", text="CONFIDENTIAL", position="diagonal", opacity=0.2)PHP
$snap->pdf->watermark(file: $bytes, kind: 'text', text: 'CONFIDENTIAL', position: 'diagonal', opacity: 0.2);Ruby
snap.pdf.watermark(file: bytes, kind: 'text', text: 'CONFIDENTIAL', position: 'diagonal', opacity: 0.2)Go
client.Watermark(ctx, &snappdf.WatermarkInput{File: bytes, Kind: "text", Text: "CONFIDENTIAL", Position: "diagonal", Opacity: 0.2})