Created
October 19, 2017 10:57
-
-
Save GroupDocsGists/3ee5f6a0350f526e3ace1b730f0fa326 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-.NET | |
| using (SlidesDocument doc = Document.Load<SlidesDocument>(Utilities.MapSourceFilePath(FilePath))) | |
| { | |
| foreach (var slide in doc.Slides) | |
| { | |
| string oldUrl = "http://aspose.com/"; | |
| // Assign null to remove hyperlink | |
| string newUrl = "http://groupdocs.com/"; | |
| // Replace hyperlinks in shapes | |
| foreach (var shape in slide.Shapes) | |
| { | |
| ReplaceHyperlink(shape, SlidesHyperlinkActionType.MouseOver, oldUrl, newUrl); | |
| ReplaceHyperlink(shape, SlidesHyperlinkActionType.MouseClick, oldUrl, newUrl); | |
| // Replace hyperlinks in text fragments | |
| foreach (var fragment in shape.FormattedTextFragments) | |
| { | |
| ReplaceHyperlink((ISlidesHyperlinkContainer)fragment, SlidesHyperlinkActionType.MouseClick, oldUrl, newUrl); | |
| ReplaceHyperlink((ISlidesHyperlinkContainer)fragment, SlidesHyperlinkActionType.MouseOver, oldUrl, newUrl); | |
| } | |
| } | |
| // Replace hyperlinks in charts | |
| foreach (var chart in slide.Charts) | |
| { | |
| ReplaceHyperlink(chart, SlidesHyperlinkActionType.MouseOver, oldUrl, newUrl); | |
| ReplaceHyperlink(chart, SlidesHyperlinkActionType.MouseClick, oldUrl, newUrl); | |
| } | |
| } | |
| // Save changes | |
| doc.Save(); | |
| } | |
| //Below is the function to replace hyperlinks | |
| private static void ReplaceHyperlink(ISlidesHyperlinkContainer hyperlinkContainer, SlidesHyperlinkActionType hyperlinkActionType, string oldUrl, string newUrl) | |
| { | |
| if (hyperlinkContainer.GetHyperlink(hyperlinkActionType) == oldUrl) | |
| { | |
| hyperlinkContainer.SetHyperlink(hyperlinkActionType, newUrl); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment