Iterate Hyperlinks/Images in the Document


https://www.nevron.com/Forum/Topic10657.aspx
Print Topic | Close Window

By Clint Carter - 5 Years Ago
How do you iterate/find all images in a document?
I want to find and delete them...

I need to find all hyperlinks inside the document.
I need to get the URL from each hyperlink.

How is this done? 



By Nevron Support - 5 Years Ago

Hi Clint,

The following code collects all images found in a text document:
NList<NNode> imageInlines = richTextView.Content.GetDescendants(NImageInline.NImageInline);
similarly for hyperlinks the code is:
NList<NNode> hyperlinkInlines = richTextView.Content.GetDescendants(NHyperlink.NHyperlinkSchema);

Regarding the hyperlink url:
NHyperlinkInline hyperlinkInline = (NHyperlinkInline)hyperlinks[0];
string url = (hyperlinkInline.Hyperlink as NUrlHyperlink).Url;

Hope this helps - let us know if you meet any problems.

By Clint Carter - 5 Years Ago
Thanks.