Extract hyperl link for a specific shapes

Is there any way to retrieve the hyperlink for each shape?

Hi Andrew,

I have observed the requirements shared by you and suggest you to please try using the following sample code on your end to extract the hyperlinks from the shape and text inside shapes.

public static void ExtractHTMlLink()
{
Presentation pptxPresentation = new Presentation(“D:\Aspose Data\HyperlinkTest.pptx”);

List HypLinks = new List();

//Get an Array of TextFrameEx objects from the first slide
ITextFrame[] textFramesSlideOne = 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);
}
}

///////////

//Loop through the Array of TextFrames
for (int j = 0; j < pptxPresentation.Slides.Count; j++)

//Loop through paragraphs in current TextFrame
foreach (IShape shape in pptxPresentation.Slides[j].Shapes)

{
if (shape.AsIHyperlinkContainer.HyperlinkClick != null)
{
HypLinks.Add(shape.AsIHyperlinkContainer.HyperlinkClick.ExternalUrl);
}
}



}

Many Thanks,

Thanks, but what if the shape is not text , an image for example. in Power point we can add hyperlink to image shapes but we can not extract them

Hi Andrew,

I like to share that the sample code that I have shared with you is workable with all shapes types. The above sample code has two parts. One iterates though text boxes while other part iterates through links associated with all shapes inside the presentation slides.

Many Thanks,

Thanks a lot, its working now.