Watermarks are a familiar visual cue in business documents. A "Confidential" or "Draft" label tells readers how a file should be handled, and a faint company logo reinforces branding without distracting from the content. Doing this by hand means opening every file, opening the watermark dialog, and repeating the same steps — error-prone when you have a folder of reports to process. With Python you can apply a consistent text or picture watermark across an entire batch of Word documents, which fits naturally into report generation or pre-distribution pipelines. This article shows how to add text watermarks, add picture watermarks, and remove watermarks using Spire.Doc for Python.
Why Add Watermarks with Python
Driving watermarks from a script has a few concrete advantages:
- Batch processing: one script stamps hundreds of documents with the same watermark, no manual clicks.
- Consistent styling: font, size, color, and angle are all set in code, so every document looks identical.
- Repeatable: watermarking becomes one step in a larger pipeline that may also convert, merge, or split files.
Setting Up the Environment
Install the Spire.Doc library:
pip install Spire.Doc
Then import the required modules in your script:
from spire.doc import *
from spire.doc.common import *
Adding a Text Watermark
A text watermark is the most common case — a word such as "Confidential" or a company name tiled across the page background. Spire.Doc represents it with a TextWatermark object. After setting the text, font size, color, and layout, assign it to document.Watermark:
from spire.doc import *
from spire.doc.common import *
# Load the Word document
document = Document()
document.LoadFromFile("Sample.docx")
# Create a text watermark and configure its appearance
txtWatermark = TextWatermark()
txtWatermark.Text = "Confidential"
txtWatermark.FontSize = 95
txtWatermark.Color = Color.get_Blue()
txtWatermark.Layout = WatermarkLayout.Diagonal
# Apply the watermark to the document
document.Watermark = txtWatermark
# Save the result
document.SaveToFile("TextWatermark.docx", FileFormat.Docx)
document.Close()
Output:
TextWatermark() constructs an empty watermark object. Text holds the string to display, FontSize controls how large the watermark text renders, Color is taken from a predefined color through a static method such as Color.get_Blue(), and Layout decides how the text is arranged — WatermarkLayout.Diagonal slants the text along the diagonal so it fills the page. Assigning the object to document.Watermark and saving writes the watermark into the file.
Adding an Image Watermark
Instead of text, you may want a company logo or seal as the watermark. The PictureWatermark object handles image watermarks; SetPicture() points to the image file, while Scaling and IsWashout adjust its size and fade:
from spire.doc import *
from spire.doc.common import *
document = Document()
document.LoadFromFile("Sample.docx")
# Create a picture watermark and configure its appearance
picture = PictureWatermark()
picture.SetPicture("Logo.png")
picture.Scaling = 250
picture.IsWashout = False
# Apply the watermark to the document
document.Watermark = picture
document.SaveToFile("ImageWatermark.docx", FileFormat.Docx)
document.Close()
Output:
SetPicture() accepts a local image path and works with common formats such as PNG and JPG. Scaling is a percentage of the image's original size — 250 places the logo at 250% of its native dimensions, which is useful when you want it prominent. IsWashout controls the "washout" fade effect; False keeps the image at full strength without fading. Assign it to document.Watermark and save.
Removing a Watermark
When a document is finalized and ready for official release, you often need to strip the draft watermark. Whether the original watermark was text or an image, setting document.Watermark to None clears it in one step:
from spire.doc import *
from spire.doc.common import *
document = Document()
document.LoadFromFile("ImageWatermark.docx")
# Setting the watermark to None removes both text and picture watermarks
document.Watermark = None
document.SaveToFile("RemoveWatermark.docx", FileFormat.Docx2013)
document.Close()
This works for both text and picture watermarks, so you do not need to track which type was applied. Note that it removes the document-level watermark; a watermark that was manually embedded as a header picture falls outside document.Watermark and is handled separately.
Practical Tips
-
Layout: besides
WatermarkLayout.Diagonal, the layout enum also offers a horizontal arrangement, so you can switch the orientation to match the document style. -
Color:
Color.get_Blue()is only one predefined color;Color.get_Red(),Color.get_Gray(), and others are available, andColor.FromArgb(r, g, b)lets you specify any custom color. -
Washout: setting
IsWashouttoTrueon a picture watermark produces a lighter, less intrusive background that works well as a brand tint. -
Resource cleanup: call
document.Close()after each document to release the file handle. - Free edition: the free edition of Spire.Doc adds an evaluation warning to the output and caps the page count, which matters when processing large batches.
Conclusion
This article covered the three common ways to work with Word watermarks in Python: TextWatermark for text watermarks, PictureWatermark for image watermarks, and assigning None to document.Watermark to remove either type. With these in hand, combined with simple file iteration, watermarking slots cleanly into automated report generation and document distribution workflows.



Top comments (0)