PDF Add Watermark
PDF Add Watermark
Section titled “PDF Add Watermark”Type: pdf-add-watermark · Package: PDF Activities v1.2.4 · Output: string
Adds a diagonal text watermark to every page of a PDF, and saves the result in a new file. Useful to mark documents as “COPY”, “CONFIDENTIAL”, “DRAFT” or with the recipient’s name.
How it works
Section titled “How it works”Draws text centred on each page, on top of the content, in Arial bold, with the given opacity, size, colour and angle, and creates a new PDF at output. Returns the path of the file created. The original stays intact.
- The text is a single line: if it is too long for the chosen size, it runs off the page. Lower
fontSizefor long texts. opacity,fontSizeandangleaccept a number or an expression (e.g.Config["Opacity"]). Since 1.2.4. A value that isn’t a number is an error, as is anopacityoutside0–1or afontSizeof0or less.- A
colorother than the three supported ones uses grey. - It creates the
outputfolder if it doesn’t exist and overwrites the file if it already exists.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
path | string | — | Path of the source PDF. |
output | string | — | Path of the resulting PDF. |
text | string | — | Watermark text. It accepts expressions (e.g. the recipient’s name). |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
opacity | number | 0.3 | Opacity from 0.0 (invisible) to 1.0 (opaque). |
fontSize | number | 48 | Font size in points. |
color | string | "gray" | Colour: gray · red · blue. |
angle | number | 45 | Rotation angle in degrees, counter-clockwise (0 = horizontal). |
Output
Section titled “Output”Returns a string with the path of the PDF created (the same as output).
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'opacity' must be a number. Received: …. (or 'fontSize', 'angle') | The typed value or the result of the expression isn’t a number. Since 1.2.4. |
'opacity' must be between 0 and 1. Received: …. | Opacity out of range; use 0.5, not 50. Since 1.2.4. |
'fontSize' must be greater than 0. Received: …. | Font size 0 or negative. Since 1.2.4. |
File not found. | The path doesn’t exist. |
'path' is required. / 'output' is required. / 'text' is required. | The parameter was left empty or its expression returned null. |
| PDF library error when opening the file | Password-protected or damaged PDF. See Protected and damaged PDFs. |
Example
Section titled “Example”Mark each copy with the recipient’s name:
PDF Add Watermark path = contractPath output = "C:/copies/" + customer.name + ".pdf" text = "COPY — " + customer.name opacity = 0.2 color = red → output: copyLog message = "Copy generated: " + copyRelated activities
Section titled “Related activities”- PDF Create — create a PDF from scratch.
- PDF Merge — combine documents.