Removing existing watermarks is another powerful feature of the GroupDocs.Watermark library. It allows searching and then removing text or image watermarks from a wide range of supported documents. Removing watermarks is possible for some of the supported formats. To learn whether it is available for your format, check Supported formats.
Note
Updating of watermarks is not allowed in evaluation mode. Please set up a license as described in Licensing and evaluation.
Deleting text watermarks
To search and remove text watermarks follow next sample:
constgroupdocs.watermark=require('@groupdocs/groupdocs.watermark')functionremoveTextWatermarks(){// Create an instance of Watermarker
constwatermarker=newgroupdocsWatermark.Watermarker('sample.pdf');// Create a TextSearchCriteria instance
constcriteria=newgroupdocsWatermark.TextSearchCriteria('test',false);constwatermarks=watermarker.search(criteria);// Remove found text fragments
watermarks.clear();// Save changes
watermarker.save('result.pdf');// Close watermarker
watermarker.close();}
Deleting image watermarks
To search and remove image watermarks within the document:
constgroupdocs.watermark=require('@groupdocs/groupdocs.watermark')functionremoveImageWatermarks(){// Create watermarker
constwatermarker=newgroupdocsWatermark.Watermarker('sample.docx');// Initialize search criteria with the image
constimageSearchCriteria=newgroupdocsWatermark.ImageDctHashSearchCriteria("logo.png");// Set maximum allowed difference between images
imageSearchCriteria.setMaxDifference(0.9);// Search for possible watermarks matching the criteria
constwatermarks=watermarker.search(imageSearchCriteria);console.log(`Found ${watermarks.getCount()} possible watermark(s).`);// Remove found text fragments
watermarks.clear();// Save changes
watermarker.save('result.docx');// Close watermarker
watermarker.close();}
Run the program. All found occurrences of image watermarks will be deleted.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.