We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to find whether the slides has external link or not?

Hi

In Aspose.Cells, we can able to find whether workbook has any external links (eg workbook.HasExernalLinks()).

Do we have the same functionality in Aspose.Slides?

Also in Aspose.Cells, we can able to find whether the links are used or not using below code

var links = workbook.Worksheets.ExternalLinks;
for (int i = 0; i < links.Count; i++)
{
logEntry.Links = links[i].DataSource;
logEntry.LinksReferred = links[i].IsReferred;
}

Do we have the same functionality in Aspose.Slides?

Regards,
David.

Hi David,


Thank you for posting.

I have observed your comments and like to request you to please try using below sample code on your end to serve the purpose.

Presentation
pres = new Presentation(“D:\test.pptx”);<o:p></o:p>

foreach (Slide sld in pres.Slides)

{

//Get an Array of TextFrameEx objects from each slide

ITextFrame[] textFrames = Aspose.Slides.Util.SlideUtil.GetAllTextBoxes(sld);

//Loop through the Array of TextFrames

for (int i = 0; i < textFrames.Length; i++)

{

//Loop through paragraphs in current TextFrame

foreach (Paragraph para in textFrames[i].Paragraphs)

{

//Loop through portions in the current Paragraph

foreach (Portion port in para.Portions)

{

try

{

if (port.PortionFormat.AsIHyperlinkContainer.HyperlinkClick.ExternalUrl != null)

{

Console.WriteLine("Slide number " + sld.SlideNumber.ToString() + " has external hyperlink");

}

}

catch { }

}

}

}

}


I hope this will be helpful. Please share if I may help you further in this regard.

Best Regards,

Hi Adnan,


Thanks for your response.

I have used the below approach for the same

Presentation pres = new Presentation(path);
uint _hlinkcnt = 0;
//Get the hyperlinks from presentation slides
foreach (ISlide slide in pres.Slides)
{
IList links = slide.HyperlinkQueries.GetAnyHyperlinks();

if(links.Count > 0)
_hlinkcnt++;

foreach (IHyperlinkContainer link in links)
{
logEntry.Links = link.HyperlinkClick.ExternalUrl;
Log.WriteToLog(logEntry);
}
}

if (_hlinkcnt > 0)
_totalFileWithLinks++;
else
Log.WriteToLog(logEntry);

//Increment Total File Counter
totalFileCounter++;


But not sure how to check how the external link is referred.
Highly appreciated if you able to help on this.

Regards,
David.

Hi David,

I have observed the sample code shared by you and like to share that it too is correct. However, I am unable to understand you following requirement.

DavidNaveen:
But not sure how to check how the external link is referred.


Can you please elaborate the requested information so that I may help you further in this regard.

Many Thanks,

Hi


Thanks for your response.

In Aspose.Cells, we can able to find whether workbook has any external links (eg workbook.HasExernalLinks()).

Do we have the same functionality in Aspose.Slides?

Also in Aspose.Cells, we can able to find whether the links are used or not using below code

var links = workbook.Worksheets.ExternalLinks;
for (int i = 0; i < links.Count; i++)
{
logEntry.Links = links[i].DataSource;
logEntry.LinksReferred = links[i].IsReferred;
}

Do we have the same functionality in Aspose.Slides?

Regards,
David

Hi David,


I have observed your requirements and have discussed them with our product team. You have questioned that if you can get the external hyperlinks from presentation or not. The answer is Yes you can but for this you need to traverse every slide. They are not managed on presentation level but every slide maintains its own list of hyperlinks. Your code in previous post describes how it can be done.

I have not been able to understand your second query that if hyperlink is used or not. I like to share that when Hyperlink is added on slide shapes they get used. It not like that you add a hyperlink on slide shapes or text and don’t use that. I hope this will be understandable.

Many Thanks,

Hi


Thanks for your response.

In Aspose.Cells below code is used to get there is any external link or not.

var links = workbook.Worksheets.ExternalLinks;
for (int i = 0; i < links.Count; i++)
{
logEntry.LinksReferred = links[i].IsReferred;
}

links[i].IsReferred returns boolean value.

Do we have the same in aspose.slides?

Regards,
David

Hi David,

As I shared in my previous post that in Aspose.Slides the hyperlink is available for any text or shape when it is set. So if there is an external hyperlink found, it is meant to be there. It’s not like that if there is an external hyperlink it is not available there. I hope this will clarify the concept to you.

Many Thanks,