ParserGetHyperlinks Method (Int32)
Extracts hyperlinks from the document page.

Namespace: GroupDocs.Parser
Assembly: GroupDocs.Parser (in GroupDocs.Parser.dll) Version: 20.8.0
Syntax
public IEnumerable<PageHyperlinkArea> GetHyperlinks(
	int pageIndex
)

Parameters

pageIndex
Type: SystemInt32
The zero-based page index.

Return Value

Type: IEnumerablePageHyperlinkArea
A collection of PageHyperlinkArea objects; null if hyperlinks extraction isn't supported.
Examples

The following example shows how to extract hyperlinks from the document page:

C#
// Create an instance of Parser class
using (Parser parser = new Parser(filePath))
{
    // Check if the document supports hyperlink extraction
    if (!parser.Features.Hyperlinks)
    {
        Console.WriteLine("Document isn't supports hyperlink extraction.");
        return;
    }
    // Get the document info
    IDocumentInfo documentInfo = parser.GetDocumentInfo();
    // Check if the document has pages
    if (documentInfo.PageCount == 0)
    {
        Console.WriteLine("Document hasn't pages.");
        return;
    }
    // Iterate over pages
    for (int pageIndex = 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 page
        IEnumerable<PageHyperlinkArea> hyperlinks = parser.GetHyperlinks(pageIndex);
        // Iterate over hyperlinks
        foreach (PageHyperlinkArea h in hyperlinks)
        {
            // Print the hyperlink text
            Console.WriteLine(h.Text);
            // Print the hyperlink URL
            Console.WriteLine(h.Url);
            Console.WriteLine();
        }
    }
}
See Also