Insert watermark in Word using Python | Add watermark to Word

A watermark in a Word document is a semi-transparent image or text that appears on the main body of the document. MS Word allows adding images like company logos as watermarks or texts such as “confidential” or “draft” as desired. Adding a watermark to Word documents is a common practice to protect your intellectual property or brand identity. In certain cases, we may need to add a watermark to Word documents (DOC or DOCX) in Python. In this blog post, we’ll explore how to insert a watermark in a Word document using Python.

This article covers the following topics:

  1. Python API to Insert Watermarks in Word Documents
  2. Insert a Text Watermark in a Word Document
  3. Insert an Image Watermark in a Word Document
  4. Free Resources

Python API to Insert Watermarks in Word Documents

The first step in adding a watermark to a Word document using Python is to install the Aspose.Words for Python library. It provides a feature-rich API that allows you to create, read, and write Word documents programmatically.

Please download the package or install the API from PyPI using the following pip command in the console:

> pip install aspose-words

Insert a Text Watermark in a Word Document using Python

Now, we can easily insert a text watermark in a Word document by following the steps below:

  1. Load the Word document using the Document class.
  2. Create an instance of the TextWatermarkOptions class.
  3. Specify watermark options such as font family, font size, color, layout, etc.
  4. After that, specify the text to show as a watermark using the set_text() method.
  5. Finally, save the updated Word document using the save() method.

The following code sample shows how to insert a text watermark in a Word document using Python.

Insert a Text Watermark in a Word Document using Python

Insert an Image Watermark in a Word Document

Similarly, we can insert an image as a watermark in a Word document by following the steps below:

  1. Load an existing Word document using the Document class.
  2. Create an instance of the ImageWatermarkOptions class to set watermark options.
  3. Specify the required watermark options, such as scale, is_washout, etc.
  4. After that, set an image using the set_image() method by providing its path.
  5. Finally, save the updated Word document using the save() method.

The following code sample shows how to insert an image watermark in a Word document using Python.

Insert an Image Watermark in a Word Document

Get a Free API License

You can get a temporary license in order to use the API without evaluation limitations.

Add Watermark to Word – Free Resources

Besides inserting text or image watermarks in Word documents, learn more about the API and explore various other features using the resources below:

Conclusion

In this article, you have learned how to insert a watermark in a Word document using Python. By following the steps outlined in this blog post, you can automate the task of adding text or image watermarks to your documents. In case of any ambiguity, please feel free to contact us on our free support forum.

See Also