GroupDocsGists
10/19/2017 - 11:11 AM

RemoveWatermarkFromSection.cs

// For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-.NET
using (WordsDocument doc = Document.Load<WordsDocument>(Utilities.MapSourceFilePath (FilePath)))
{
    // Initialize search criteria
    ImageSearchCriteria imageSearchCriteria = new ImageDctHashSearchCriteria(@"D:\logo.png");
    TextSearchCriteria textSearchCriteria = new TextSearchCriteria("Company Name");

    // Call FindWatermarks method for the section
    PossibleWatermarkCollection possibleWatermarks = doc.Sections[0].FindWatermarks(textSearchCriteria.Or(imageSearchCriteria));

    // Remove all found watermarks
    for (var i = possibleWatermarks.Count - 1; i >= 0; i--)
    {
        possibleWatermarks.RemoveAt(i);
    }

    doc.Save();
}