watermark object is an instance accessible from the main MuPDFWebViewer instance as follows:
const watermark = webViewer.watermark;
This assumes you have returned your instance name as
webViewer from the initMuPDFWebViewer() promise!watermark
Thewatermark object has the following methods:
create
create(config: { watermarks: (TextWatermark | ImageWatermark)[] }): Promise<undefined>;
Parameters
An object containing an array of text or image watermarks.
Show config properties
Show config properties
Array of text or image watermarks.
Show TextWatermark properties
Show TextWatermark properties
Watermark type.
Opacity.
Watermark alignment.
Rotation angle.
X coordinate.
Y coordinate.
Whether visible in viewer.
Whether printed.
Page range.
Watermark text.
Font size.
Text color.
Font family name.
Bold style.
Italic style.
Optional border config.
Vertical repeat interval.
Horizontal repeat interval.
Show TextWatermark.border properties
Show TextWatermark.border properties
Show ImageWatermark properties
Show ImageWatermark properties
Watermark type.
Opacity.
Watermark alignment.
Rotation angle.
X coordinate.
Y coordinate.
Whether visible in viewer.
Whether printed.
Page range.
Image scale.
Image path.
Vertical repeat interval.
Horizontal repeat interval.
Returns
A Promise.
webViewer.watermark.create({
watermarks: [
{
type: 'Text',
opacity: 0.2,
align: 'CENTER',
rotate: 45,
x: 0,
y: 0,
text: 'CONFIDENTIAL',
size: 32,
color: '#ff0000',
fontName: 'Helvetica',
allowView: true,
allowPrint: true
},
{
type: 'Image',
opacity: 0.4,
align: 'BOTTOM_RIGHT',
rotate: 0,
x: 0,
y: 0,
scale: 0.5,
imagePath: '/watermark.png'
}
]
});
Supporting Types
WatermarkAlignment
export enum WatermarkAlignment {
CENTER = 'CENTER',
TOP_LEFT = 'TOP_LEFT',
TOP = 'TOP',
TOP_RIGHT = 'TOP_RIGHT',
LEFT = 'LEFT',
RIGHT = 'RIGHT',
BOTTOM_LEFT = 'BOTTOM_LEFT',
BOTTOM = 'BOTTOM',
BOTTOM_RIGHT = 'BOTTOM_RIGHT'
}
TextWatermark
export interface TextWatermark {
type: 'Text';
opacity: number;
align?: WatermarkAlignment;
rotate: number;
x: number;
y: number;
allowView?: boolean;
allowPrint?: boolean;
range?: string;
text: string;
size: number;
color: string;
fontName: string;
bold?: boolean;
italic?: boolean;
border?: {
width?: number;
height?: number;
color: string;
strokeWidth: number;
horizontalPadding?: number;
verticalPadding?: number;
};
repeatHeight?: number;
repeatWidth?: number;
}
ImageWatermark
export interface ImageWatermark {
type: 'Image';
opacity: number;
align?: WatermarkAlignment;
rotate: number;
x: number;
y: number;
allowView?: boolean;
allowPrint?: boolean;
range?: string;
scale: number;
imagePath: string;
repeatHeight?: number;
repeatWidth?: number;
}