Three kinds of PDF watermarks, and why most removers only handle one
"Just remove the watermark" is one of those tasks that sounds trivial until you open the file. I've lost count of how many times someone has told me a tool "doesn't work", when the real issue was that they were dealing with a different kind of watermark than the tool was built for. There are three, and they live in completely different places in the file. Type 1: an annotation This is the easy…
When it comes to removing watermarks from PDF files, many people assume the process is straightforward. However, there are actually three distinct types of watermarks, each requiring a different approach to eliminate. Tools that only handle one type of watermark often fail when confronted with the others.
The first type of watermark is an annotation. This is the simplest case, as the watermark appears as an object in the page's /Annots array, similar to sticky notes or highlights. It's drawn on top of the page content but isn't part of it. Any tool capable of editing annotations can remove it. On a command line, you can check for annotations using pdfinfo and qpdf commands.
The second type is a Form XObject. This is a more complex scenario. The watermark is a reusable content object referenced from the page's resource dictionary and painted via a Do operator in the content stream. It's now part of the page content, so simply deleting the annotation won't work. Removing a Form XObject requires locating the XObject in the /Resources /XObject dictionary, following the mapping through /Form and the Matrix × Do CTM combination, deleting the object and its reference, and rewriting the stream back while clearing stale filter keys. These steps are often overlooked by simple text-matching approaches.
The third type is when the watermark is baked into a scanned image. In this case, the watermark is pixels, not vector data. No PDF-level tool can remove it; you'd need to use image editing software, which usually results in unsatisfactory outcomes. A quick way to check if a PDF is a scan is by using the pdftotext command and counting the number of characters. If the output is almost nothing, you're dealing with a scanned document, not a PDF.
To determine which type of watermark you're dealing with, you can use a few quick heuristics. Running pdfinfo on the PDF and searching for "pages" can give you a clue. If pdftotext returns almost no text, you're likely looking at a scanned image. You can also use qpdf with specific options to search for /Annots or /XObject entries in the stream. If /Annots shows up with a /Subtype of /Watermark, you're dealing with type 1. If you find /XObject forms that don't correspond to visible images, it's likely type 2.
Regardless of the type, it's essential to verify that the watermark has been completely removed. Some tools only draw an opaque rectangle over the watermark, leaving the underlying text intact. This can be easily checked by running pdftotext on the cleaned file and searching for sensitive words or phrases. If anything appears, the file is not clean. Tools that properly remove content should pass this check, but it's a good practice to verify regardless of the type.
In summary, removing watermarks from PDFs isn't as simple as it seems. There are three distinct types of watermarks, each requiring a different approach. Understanding which type you're dealing with can save you a lot of time and frustration when trying to clean up your PDF files.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.