Remove watermark to PDF in Python

Watermarks in PDF files are used to insert logos, trademarks, or a piece of text on the pages. The purpose of watermarking could be protecting confidential information, asserting copyright, etc. While processing PDF files programmatically, you often have to remove the watermarks added to PDF pages. To accomplish that, this article shows you how to remove watermarks from a PDF in Python.

Python Library to Remove Watermarks in PDF

To remove watermarks from PDF files, we will use Aspose.PDF for Python. It is a powerful PDF manipulation library that lets you add and remove PDF watermarks within a few simple steps. You can install the library using the following pip command.

pip install aspose-pdf

Remove Watermark from a PDF in Python

In a PDF file, the watermarks are represented as artifacts. Therefore, to remove watermarks, we will have to access artifacts on each page of the PDF. The following are the steps to remove watermarks from a PDF in Python.

  • First, load the PDF file using Document class.
  • Then, create an array to keep references of the artifacts to be removed.
  • Loop through each page of the PDF using Document.pages collection and in each iteration, perform the following steps:
    • Access each artifact of the page from Page.artifacts collection.
    • Check if the type of the artifact is Artifact.artifact_subtype.WATERMARK.
    • If yes, add the artifact to the array.
  • Finally, loop through the artifacts to be deleted and remove each artifact using Page.artifacts.delete() method.
  • At the end, save the updated PDF file using method.

The following code sample shows how to remove watermarks from a PDF in Python.

Watermark PDF Files Online

Try our free online tool for PDF watermarking, which is developed using Aspose.PDF. You can use this tool without creating an account.

Get a Free License

Get a free temporary license and try the watermark removing feature without any limitations.

Explore Python PDF Library

Explore other features of Aspose.PDF for Python using the documentation. In case you would have any questions or queries, do let us know via our forum.


In this article, you have learned how to remove watermarks from PDF files in Python. The detailed guidelines and Python code sample have demonstrated how to access and remove watermarks from each page in a PDF file. In addition, we have provided you with a free web-based PDF watermarking tool that you can use anywhere at any time for free.

See Also