Skip to main content

addWatermarkRender

(Pro version only. Requires RxCore version 37.14 or newer.)

The addWatermarkRender method adds a temporary (render-only) watermark to the active document viewer.
This watermark is not embedded into the PDF and will not appear in exported or printed documents.

NB! this can not be removed using the removeWatermarkFromAllPages method.

Use this for dynamic, session-based, or user-specific watermarks such as timestamps, usernames, or “For internal use only” labels.

Example

async function applyWatermark() {
const text = document.getElementById("wmText").value;
const settings = {
fontUrl: document.getElementById("wmFontUrl").value, // Optional custom font URL (.ttf)
fontName: document.getElementById("wmFontName").value, // Custom font name
fontSize: parseInt(document.getElementById("wmFontSize").value, 10),
color: document.getElementById("wmColor").value, // e.g., "#FF0000"
rotation: parseInt(document.getElementById("wmRotation").value, 10),
opacity: parseInt(document.getElementById("wmOpacity").value, 10),
scale: parseFloat(document.getElementById("wmScale").value),
position: document.getElementById("wmPosition").value, // "Center", "TopLeft", etc.
useRelativeScale: true,
offsetX: 0,
offsetY: 0,
fontStyle: "normal"
};

const viewerCore = viewerFrame?.contentWindow?.RxCore;
if (viewerCore && typeof viewerCore.addWatermarkRender === "function") {
await viewerCore.addWatermarkRender(text, settings);
console.log("✅ Watermark applied through iframe viewer.");
} else {
console.error("❌ RxCore.addWatermarkRender not available inside iframe.");
}
}

Syntax

await viewerCore.addWatermarkRender(text, settings);

Parameters

ParameterTypeDescription
textstringThe watermark text to display.
settingsobject (optional)Configuration for appearance and positioning.
Supported Settings

In addition to the standard watermark options, the following extra fields are supported:

PropertyTypeDescription
fontUrlstringURL to a custom font file (e.g., .ttf).
fontNamestringName of the custom font (used with fontUrl).
fontSizenumberFont size in points.
colorstringFont color as a hex string (e.g., "#FF0000").
rotationnumberRotation angle in degrees.
opacitynumberOpacity level (0–100).
scalenumberScale factor.
positionstring"Center", "TopLeft", etc.
useRelativeScalebooleanIf true, scales relative to page size.
offsetX / offsetYnumberManual X/Y offsets.
fontStylestring"normal", "italic", or "bold".