Skip to content

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.

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 fontSize for long texts.
  • opacity, fontSize and angle accept 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 an opacity outside 0–1 or a fontSize of 0 or less.
  • A color other than the three supported ones uses grey.
  • It creates the output folder if it doesn’t exist and overwrites the file if it already exists.
ParameterTypeDefaultDescription
pathstring—Path of the source PDF.
outputstring—Path of the resulting PDF.
textstring—Watermark text. It accepts expressions (e.g. the recipient’s name).
ParameterTypeDefaultDescription
opacitynumber0.3Opacity from 0.0 (invisible) to 1.0 (opaque).
fontSizenumber48Font size in points.
colorstring"gray"Colour: gray · red · blue.
anglenumber45Rotation angle in degrees, counter-clockwise (0 = horizontal).

Returns a string with the path of the PDF created (the same as output).

MessageCause 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 filePassword-protected or damaged PDF. See Protected and damaged PDFs.

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: copy
Log message = "Copy generated: " + copy