Enterprises that distribute PDF contracts, marketing collateral, or technical manuals often embed watermarks to protect intellectual property and enforce branding rules. Manually opening each file to verify that a specific text watermark (e.g., “Confidential”) appears on every page is error-prone, especially when thousands of documents are involved. This use-case shows how to automate a full-document audit using Watermarker and TextSearchCriteria, confirm that the required watermark exists on every page, verify formatting rules, and produce a concise compliance report.
Combine TextSearchCriteria with TextFormattingSearchCriteria using the .And() operator to check font, size, and bold style in addition to text presence:
vartextCriteria=newTextSearchCriteria(expectedText);// Check text + font namevarfontCriteria=newTextFormattingSearchCriteria{FontName="Arial"};CheckRule(watermarker,textCriteria.And(fontCriteria),"Font 'Arial'",refpassed,reffailed);// Check text + minimum font sizevarsizeCriteria=newTextFormattingSearchCriteria{MinFontSize=15};CheckRule(watermarker,textCriteria.And(sizeCriteria),"Min font size >= 15",refpassed,reffailed);
A separate helper verifies page coverage by collecting watermarked page numbers and comparing against the total page count. The final verdict is COMPLIANT or NON-COMPLIANT.
4. Replace outdated watermark text
Locate watermarks by old text, clear their FormattedTextFragments, and add new text with updated font and color:
The screenshot below shows the result — the old watermark text has been replaced with the new text, font, and color:
Note
The sample project also demonstrates adding invisible tracking watermarks for leak detection and recovering them with regex-based TextSearchCriteria. See AddTrackingWatermark and DetectTrackingWatermark in Program.cs.
The RemoveWatermarksByCriteria method in the sample project demonstrates targeted removal — only watermarks matching both text and formatting criteria are deleted:
Notes
The sample works with any document format supported by GroupDocs.Watermark (DOCX, PPTX, etc.). Replace the *.pdf filter with *.* to audit a mixed folder.
For large collections, consider processing files in parallel (Parallel.ForEach) — the Watermark SDK is thread-safe when each thread uses its own Watermarker instance.
If you need to audit encrypted PDFs, pass the password to Watermarker via the constructor overload.
The free evaluation license limits the number of processed pages; acquire a full license for production workloads.