Extract hyperlinks from document page area

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Parser MCP server lets your agent work with files on your machine; they are never uploaded. It runs in Docker: replace /path/to/documents with the folder it may use.

claude mcp add groupdocs-parser -- docker run --rm -i -v /path/to/documents:/data ghcr.io/groupdocs-parser/parser-net-mcp:latest
Folders, licensing and more →

GroupDocs.Parser provides the functionality to extract hyperlinks from document page area by the getHyperlinks(PageAreaOptions) and getHyperlinks(int, PageAreaOptions) methods:

Iterable<PageHyperlinkArea> getHyperlinks(PageAreaOptions options);
Iterable<PageHyperlinkArea> getHyperlinks(int pageIndex, PageAreaOptions options);

These methods return a collection of PageHyperlinkArea object:

MemberDescription
getPageThe page that contains the text area.
getRectangleThe rectangular area on the page that contains the text area.
getTextThe hyperlink text.
getUrlThe hyperlink URL.

Here are the steps to extract hyperlinks from the document page area:

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

// Create an instance of Parser class
try (Parser parser = new Parser(Constants.HyperlinksPdf)) {
    // Check if the document supports hyperlink extraction
    if (!parser.getFeatures().isHyperlinks()) {
        System.out.println("Document isn't supports hyperlink extraction.");
        return;
    }
    // Create the options which are used for hyperlink extraction
    PageAreaOptions options = new PageAreaOptions(new Rectangle(new Point(380, 90), new Size(150, 50)));
    // Extract hyperlinks from the document page area
    Iterable<PageHyperlinkArea> hyperlinks = parser.getHyperlinks(options);
    // Iterate over hyperlinks
    for (PageHyperlinkArea h : hyperlinks) {
        // Print the hyperlink text
        System.out.println(h.getText());
        // Print the hyperlink URL
        System.out.println(h.getUrl());
        System.out.println();
    }
}

More resources

GitHub examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free online image extractor App

Along with full featured .NET library we provide simple, but powerfull free APPs.

You are welcome to extract images from PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, Emails and more with our free online GroupDocs Parser App.