// Specify an absolute or relative path to your document. Ex: @"C:\Docs\document.pdf"using(Watermarkerwatermarker=newWatermarker("document.pdf")){PossibleWatermarkCollectionpossibleWatermarks=watermarker.Search();// Remove possible watermark at the specified index from the document.possibleWatermarks.RemoveAt(0);// Remove specified possible watermark from the document.possibleWatermarks.Remove(possibleWatermarks[0]);watermarker.Save("document.pdf");}
Remove watermark with particular text formatting
GroupDocs.Watermark also enables you to search and remove the watermarks on the basis of some particular text formatting. You can provide a search criterion containing font name, size, color etc and the API will find the watermarks with matching properties. Following code snippet shows how to search and remove watermarks with a particular text formatting.
// Specify an absolute or relative path to your document. Ex: @"C:\Docs\document.pdf"using(Watermarkerwatermarker=newWatermarker("document.pdf")){TextFormattingSearchCriteriacriteria=newTextFormattingSearchCriteria();criteria.ForegroundColorRange=newColorRange();criteria.ForegroundColorRange.MinHue=-5;criteria.ForegroundColorRange.MaxHue=10;criteria.ForegroundColorRange.MinBrightness=0.01f;criteria.ForegroundColorRange.MaxBrightness=0.99f;criteria.BackgroundColorRange=newColorRange();criteria.BackgroundColorRange.IsEmpty=true;criteria.FontName="Arial";criteria.MinFontSize=19;criteria.MaxFontSize=42;criteria.FontBold=true;PossibleWatermarkCollectionwatermarks=watermarker.Search(criteria);watermarks.Clear();watermarker.Save("document.pdf");}
Remove hyperlink watermarks
GroupDocs.Watermark API allows you to search and remove hyperlinks in a document of any supported format. Following code sample shows how to find and remove hyperlinks with a particular URL from a document.
// Specify an absolute or relative path to your document. Ex: @"C:\Docs\document.pdf"using(Watermarkerwatermarker=newWatermarker("document.pdf")){PossibleWatermarkCollectionwatermarks=watermarker.Search(newTextSearchCriteria(newRegex(@"someurl\.com")));for(inti=watermarks.Count-1;i>=0;i--){// Ensure that only hyperlinks will be removed.if(watermarks[i]isHyperlinkPossibleWatermark){// Output the full url of the hyperlinkConsole.WriteLine(watermarks[i].Text);// Remove hyperlink from the documentwatermarks.RemoveAt(i);}}watermarker.Save("document.pdf");}
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.