Find and Remove Watermarks from Documents in Java

This article is useful for the Java developers who are looking for a way to find and remove text or image watermarks from PDF, Word, Excel, PowerPoint, Visio and Email documents.

GroupDocs.Watermark for Java API supports adding text and image watermarks to a wide range of document formats. In addition, it also has the ability to find and remove watermarks from the documents. The API also finds the watermark objects that are added using the third-party tools. So let me demonstrate how you can remove the watermark from a document in a few steps in Java.

Before we begin, have a look at the following PDF document which contains a text as well as an image watermark. We’ll use this document and remove the watermarks from it.

Steps to remove watermarks from a document

1. Create a new project.

2. Add the following imports.

3. Create an instance of Document class and load the source document.

4. Find the watermarks based on search criteria using findWatermarks method (if you don’t pass any searching criteria, findWatermark will return all the possible watermark objects).

5. Iterate over the watermark collection and remove watermarks using removeAt method.

6. Save the resultant document using save method.

Complete Code


The following is the screenshot of the resultant PDF document that we get after removing the watermarks.

Explore more about GroupDocs.Watermark for Java API here. In case of any queries, reach us at our forum.