GroupDocsGists
10/19/2017 - 10:59 AM

RemoveHyperlinksWithParticularURL.cs

// For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-.NET
using (Document doc = Document.Load(Utilities.MapSourceFilePath(DocFilePath)))
{
    PossibleWatermarkCollection watermarks = doc.FindWatermarks(new TextSearchCriteria(new Regex(@"someurl\.com")));
    for (int i = watermarks.Count - 1; i >= 0; i--)
    {
        // Ensure that only hyperlinks will be removed.
        if (watermarks[i] is HyperlinkPossibleWatermark)
        {
            // Output the full url of the hyperlink
            Console.WriteLine(watermarks[i].Text);

            // Remove hyperlink from the document
            watermarks.RemoveAt(i);
        }
    }
    doc.Save();
}