插入水印
在文档的每一页插入或移除自定义水印。
(function () {
let doc = Api.GetDocument();
let action = "insert"; // 将"insert"修改为 "remove" 以删除水印
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();
}
})();
使用方法: GetDocument, GetWatermarkSettings, SetType, SetText, GetTextPr, SetFontFamily, SetFontSize, SetDoubleStrikeout, SetItalic, SetBold, SetUnderline, SetColor, SetHighlight, SetTextPr, SetWatermarkSettings, RemoveWatermark
结果