Iterate through the collection and get a hyperlink text and URL.
The following example shows how to extract hyperlinks from the document page:
// Create an instance of Parser classusing(Parserparser=newParser(filePath)){// Check if the document supports hyperlink extractionif(!parser.Features.Hyperlinks){Console.WriteLine("Document isn't supports hyperlink extraction.");return;}// Get the document infoIDocumentInfodocumentInfo=parser.GetDocumentInfo();// Check if the document has pagesif(documentInfo.PageCount==0){Console.WriteLine("Document hasn't pages.");return;}// Iterate over pagesfor(intpageIndex=0;pageIndex<documentInfo.PageCount;pageIndex++){// Print a page number Console.WriteLine(string.Format("Page {0}/{1}",pageIndex+1,documentInfo.PageCount));// Extract hyperlinks from the document pageIEnumerable<PageHyperlinkArea>hyperlinks=parser.GetHyperlinks(pageIndex);// Iterate over hyperlinksforeach(PageHyperlinkAreahinhyperlinks){// Print the hyperlink textConsole.WriteLine(h.Text);// Print the hyperlink URLConsole.WriteLine(h.Url);Console.WriteLine();}}}
More resources
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples: