This article is useful for Java developers who are looking for a way to find and remove text or image watermarks from PDF, Word, Excel, PowerPoint, and Visio documents. In one of our posts we have learnt finding and removing watermarks from documents in C#. Let’s now jump to quickly see a little about a Java API that allows adding, finding and removing watermarks from various documents in different ways.

Java API for Watermarking and Removal

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.

You may get the JAR from downloads section, or add the following configuration in pom.xml of your Maven-based Java application. For API details, visit API Reference.

	<name>GroupDocs Java API</name>

Steps to Remove Watermarks from a Document in Java

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

PDF file with watermarks - GroupDocs

1. Create a new project.

2. Add the following imports.

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

4. Find the watermarks based on the configured search criteria using search method.

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

6. Save the resultant document using save method.

There are also some other ways of finding and removing watermarks from documents using different methods. If you want to remove all the watermarks of a document, or want to get rid of some selective watermarks of various kind:

  • You can collect all the possible watermarks.
  • Iterate over the watermark collection or directly access the watermark with index.
  • Check for watermark type and data, if required.
  • Remove it, if it meets your requirement.

remove, removeAt, and clear are the methods that can be used accordingly for removing watermarks. For more details, you can visit documentation article about searching and modifying watermarks in Java.

Complete Code


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

Resultant PDF file after removal of watermarks using Watermarking Java API by GroupDocs


I believe, as a Java developer, you will not be hesitant any more to find and then remove any kind of watermarks from Microsoft and OpenOffice supported word-processing documents, spreadsheets, presentations, PDF documents, and Visio drawings.

You may explore more about the API from the documentation. In case of any queries, reach us @ forum.

See Also