Learn How to Insert a Watermark in Word Document using Python
Last active
July 29, 2024 05:33
-
-
Save aspose-com-gists/bfe6353776cd117151b439827d919697 to your computer and use it in GitHub Desktop.
How to Insert Watermark in Word Document using Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Load a Word document | |
| doc = aw.Document("Document.docx"); | |
| # Specify watermark options for image | |
| options = aw.ImageWatermarkOptions() | |
| options.scale = 3 | |
| options.is_washout = False | |
| # Provide the image path | |
| doc.watermark.set_image("logo.png", options); | |
| # Save the document | |
| doc.save("AddImageWatermark_out.docx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Load a Word document | |
| doc = aw.Document("Document.docx") | |
| # Specify watermark options for text | |
| options = aw.TextWatermarkOptions() | |
| options.font_family = "Arial" | |
| options.font_size = 72 | |
| options.color = drawing.Color.black | |
| options.layout = aw.WatermarkLayout.DIAGONAL | |
| options.is_semitrasparent = True | |
| # Specify the text to show as a watermark | |
| doc.watermark.set_text("CONFIDENTIAL", options); | |
| # Save the document | |
| doc.save("AddTextWatermark_out.docx"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment