The following code snippet shows how to apply the watermark to the output pages.
fromgroupdocs.viewerimportViewerfromgroupdocs.viewer.optionsimportHtmlViewOptions,Watermarkdefadd_text_watermark():# Load documentwithViewer("sample.docx")asviewer:# Create an HTML file.viewOptions=HtmlViewOptions.for_embedded_resources("add_text_watermark/output-watermark.html")# Add watermark.viewOptions.watermark=Watermark("This is a watermark")viewer.view(viewOptions)if__name__=="__main__":add_text_watermark()
sample.docx is the sample file used in this example. Click here to download it.