/// <summary> /// Removes hyperlinks with a particular URL /// </summary> public static void RemoveHyperlinksWithParticularURL() { try { //ExStart:RemoveHyperlinksWithParticularURL using (Document doc = Document.Load(Utilities.MapSourceFilePath(DOC_FILE_PATH))) { 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(); } //ExEnd:RemoveHyperlinksWithParticularURL } catch (Exception exp) { Console.Write(exp.Message); } }
/// <summary> /// Removes watermark /// </summary> public static void RemoveWatermark() { try { //ExStart:RemoveWatermark using (Document doc = Document.Load(Utilities.MapSourceFilePath(XLS_FILE_PATH))) { PossibleWatermarkCollection possibleWatermarks = doc.FindWatermarks(); // Remove possible watermark at the specified index from the document. possibleWatermarks.RemoveAt(0); // Remove specified possible watermark from the document. possibleWatermarks.Remove(possibleWatermarks[0]); doc.Save(); } //ExEnd:RemoveWatermark } catch (Exception exp) { Console.Write(exp.Message); } }