is there anyway to loop through hyperlinks in Powerpoint presentation and identify on which slide hyperlink is?
I am using HyperlinkQueries.GetAnyHyperlinks to loop through collection but was not able to find way to match identified hyperlink and slide where it is.
Well, text is wrong. If hyperlink is on some slide behind text it is easy to find slide number.
Problem is with following scenario:
on slide you have image which is with hyperlink
to find hyperlink I am using HyperlinkQueries.GetAnyHyperlinks which is helping me find links but I cannot find slide number
Reason for this is that I have request to check all links in Powerpoint presentation and report broken links. If I cannot find where they are my end users will have issues to figure out what has to be repaired.
I have observed the requirements shared by you and like to share that if you want to get the slide or respective shape index on which hyperlink is set then you need to traverse all slides and every shape inside each slide to access the hyperlink. This way you will be able to get the slide index and also the shape index on which hyperlink is applied. I suggest you to please visit the below thread link for your convenience as well.
I have copied the solution for your convenience below. It updates the hyperlink as well as the portion text.
Presentation pptxPresentation = new Presentation("D:\test.pptx");
List HypLinks = new List();
//Get an Array of TextFrame objects from the first slide
ITextFrame[] textFramesSlideOne = Aspose.Slides.Util.SlideUtil.GetAllTextBoxes(pptxPresentation.Slides[0]);
//Loop through the Array of TextFrames
for (int i = 0; i < textFramesSlideOne.Length; i++)
//Loop through paragraphs in current TextFrame
foreach (Paragraph para in textFramesSlideOne[i].Paragraphs)
//Loop through portions in the current Paragraph
foreach (Portion port in para.Portions)
{
if (port.PortionFormat.AsIHyperlinkContainer.HyperlinkClick != null)
{
HypLinks.Add(port.PortionFormat.AsIHyperlinkContainer.HyperlinkClick.ExternalUrl);
port.PortionFormat.HyperlinkManager.SetExternalHyperlinkClick("customURL.com");
port.Text = "customtext";
}
}
pptxPresentation.Save(@"D:\test.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
I hope this will be helpful. Please share if I may help you further in this regard.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.