Skip to main content

Insert watermark

Inserts or removes a custom watermark on every page of the document.

(function () {
let doc = Api.GetDocument();
let action = "insert"; // Change to "remove" to delete watermark

if (action === "insert") {
let watermarkSettings = doc.GetWatermarkSettings();

watermarkSettings.SetType("text");
watermarkSettings.SetText("Example Watermark");

let textProperties = watermarkSettings.GetTextPr();
textProperties.SetFontFamily("Calibri");
textProperties.SetFontSize(48);
textProperties.SetDoubleStrikeout(true);
textProperties.SetItalic(true);
textProperties.SetBold(true);
textProperties.SetUnderline(true);
textProperties.SetColor(0, 255, 0, false);
textProperties.SetHighlight("blue");

watermarkSettings.SetTextPr(textProperties);
doc.SetWatermarkSettings(watermarkSettings);
} else if (action === "remove") {
doc.RemoveWatermark();
}
})();

Methods used: GetDocument, GetWatermarkSettings, SetType, SetText, GetTextPr, SetFontFamily, SetFontSize, SetDoubleStrikeout, SetItalic, SetBold, SetUnderline, SetColor, SetHighlight, SetTextPr, SetWatermarkSettings, RemoveWatermark

Result

WatermarkInserter WatermarkInserter