This code example shows how to extract all hyperlinks from a PDF file using custom options.
C#
// Initialize the Parser with the PDF document
using (Parser parser = new Parser("input.docx"))
{
// Check if hyperlink extraction is supported
if (!parser.Features.Hyperlinks)
{
return;
}
// Set link extraction options to narrow results
PageAreaOptions options = new PageAreaOptions(new Rectangle(new Point(380, 90), new Size(150, 50)));
// Extract hyperlink data from the document
IEnumerable<PageHyperlinkArea> hyperlinks = parser.GetHyperlinks(options);
// Handle the list of extracted links
foreach (PageHyperlinkArea h in hyperlinks)
{
Console.WriteLine(h.Text);
Console.WriteLine(h.Url);
}
}