LogoDOCS
OverviewAuthenticationRate LimitsErrors
Logo
Sign in →

Watermark PDF

The Watermark PDF endpoint adds a watermark to an existing PDF document. You can apply either a text watermark or an image watermark, depending on your needs.

Request Body
filefilerequired if documentId is not provided

File type: .pdf

The source PDF file to watermark. Either file or documentId must be provided.

documentIdstringrequired if uploaded file is not provided

The unique identifier of an existing uploaded document. Use this when watermarking a file that's already stored on our database.

watermarkfile

File types: .png .jpeg .jpg

The image to be used as a watermark. Provide this field if you want an image watermark instead of text.

fontFilefile

File types: .ttf .otf

A custom font file for text watermarks.

typestringrequired
Acceptable values:
textimage

Use text for a text watermark and image for an image watermark.

textstringrequired if type is set to text

The text you want to appear as the watermark.

fontstring

Default: helvetica

Acceptable values:
times-romantimes-boldtimes-italictimes-bolditalichelveticahelvetica-boldhelvetica-obliquehelvetica-boldobliquecouriercourier-boldcourier-obliquecourier-boldoblique

The font name to use for the text watermark. Must be one of the standard PDF fonts. If the fontFile is provided, this parameter will be ignored.

fontSizenumber

Default: 30

The size of the watermark text, in points.

fontColorstring

The color of the text watermark. Accepts a hex color (e.g., #FF0000) or an RGB value (e.g., rgb(255,0,0)).

opacitynumber

Default: 1

Sets the transparency of the watermark, from 0 (fully transparent) to 1 (fully opaque). It applies to both text and image watermarks.

xPositionnumber

The horizontal position (in points) where the image or text watermark will be placed. If not provided a centered position will be applied.

yPositionnumber

The vertical position (in points) where the image or text watermark will be placed. If not provided, a centered position will be applied.

imageWidthnumber

The width (in points) to resize the watermark image to. If not provided, the image keeps its original width.

imageHeightnumber

The height (in points) to resize the watermark image to. If not provided, the image keeps its original height.

rotatenumber

Rotates the watermark by the specified angle in degrees (0-360). Useful for diagonal watermarks.

jsonResponseboolean

Default: false

Returns JSON response instead of file stream.

preSignedUrlExpiresInnumber

Minimum: 60 seconds

Maximum: 86400 seconds (24 hours)

Use this to control temporary authorized access to files. After this duration, the URL automatically expires and can no longer be used to download the PDF. The value must be provided in seconds.

If you need to generate a new pre-signed URL for an existing document, use the Get Document endpoint.

metadataobject

Sets custom data to your document record.

POST/watermark/pdf
CURL
NODE.JS
PYTHON
GO
PHP
JAVA
C#
RUBY
1curl -X POST "https://api.pdfgate.com/watermark/pdf" \2  -H "Authorization: Bearer YOUR_API_KEY" \3  -F "file=@YOUR_FILE.pdf" \4  -F "type=text" \5  -F "text=My watermark!" \6  -F "fontColor=rgb(156, 50, 168)" \7  -F "rotate=30" \8  -F "opacity=0.2" \9  --output watermarked.pdf
File stream response
1File stream
JSON response - Document object
1{2  "id" : "6642381c5c61",3  "status" : "completed",4  "fileUrl" : "https://api.pdfgate.com/file/open/:preSignedUrlToken",5  "size" : 1620006,6  "type" : "watermarked",7  "derivedFrom" : "68f920bacfe16de217f019as",8  "createdAt" : "2024-02-13T15:56:12.607Z"9}