Skip to main content

addWatermarkToAllPages

Add Watermark

The viewer provides functionality to add text watermarks to PDF documents.
You can add watermarks to all pages using the addWatermarkToAllPages method.

// Add a simple watermark with default settings
RxCore.addWatermarkToAllPages("CONFIDENTIAL");

// Add a watermark with custom settings
RxCore.addWatermarkToAllPages('Rasterex', {
position: 'Center',
offsetX: 0,
offsetY: 0,
scale: 1,
opacity: 50,
font: 4,
rotation: 45
});

Watermark Options

The watermark function accepts two parameters:

  • text: The text to display as watermark
  • settings: An optional object containing watermark configuration

Available settings with their default values:

{
// Configuration settings
useRelativeScale: true,
/*
Determines if the scale is relative to the target page.
If true, use "settings.scale" to control the text size.
If false, use "settings.fontSize" to control the text size.
Default: true
*/

// Watermark Position and Layout
position: "Center", // Position of the watermark
offsetX: 0, // Horizontal offset from position
offsetY: 0, // Vertical offset from position
scale: 1, // Scale factor of the watermark
rotation: 45, // Rotation angle in degrees
opacity: 100, // Opacity percentage (0–100)

// Text Properties
font: 2, // Font identifier
fontSize: 20, // Font size in points
color: 0x000000, // Text color in hexadecimal
fontStyle: "normal", // Font style
flags: 2 // Watermark on top of content
}

Font Table

EnumeratorNumberFont Name
courier0Standard font: Courier.
courierBold1Standard font: Courier-Bold.
courierBoldOblique2Standard font: Courier-BoldOblique (Bold Italic).
courierOblique3Standard font: Courier-Oblique (Italic).
helvetica4Standard font: Helvetica.
helveticaBold5Standard font: Helvetica-Bold.
helveticaBoldOblique6Standard font: Helvetica-BoldOblique (Bold Italic).
helveticaOblique7Standard font: Helvetica-Oblique (Italic).
timesRoman8Standard font: Times-Roman.
timesBold9Standard font: Times-Bold.
timesBoldItalic10Standard font: Times-BoldItalic.
timesItalic11Standard font: Times-Italic.
symbol12Standard font: Symbol.
zapfDingbats13Standard font: ZapfDingbats.

Position Values

Use these string values for the watermark position. These values are case-sensitive.

String ValuePosition Description
"TopLeft"Top left position
"TopCenter"Top center position
"TopRight"Top right position
"CenterLeft"Center left position
"Center"Center position
"CenterRight"Center right position
"BottomLeft"Bottom left position
"BottomCenter"Bottom center position
"BottomRight"Bottom right position

Flags

EnumeratorNumberEffect
asContent0Watermark becomes part of the page content.
asAnnot1Watermark is inserted as an annotation.
onTop2Watermark is displayed above other page content.
unprintable3Watermark is not printed.
display4Watermark is not displayed.