[SerializableAttribute()]public struct PDFHyperlink
The PDFHyperlink structure contains information of a single PDF hyperlink. To read hyperlinks from a PDF file, use the PDFDocument.ParsePages method with the PDFParsePagesOptions.Hyperlinks specified in the options parameter passed to the method. The PDFDocumentPage'sPDFDocumentPage.Hyperlinks collections will be populated with the hyperlinks of the page.
A hyper link is not a visible object on the page, rather, it is parsed from the text of the object. So for every hyperlink on a page, there will also exist the actual PDFObject of type PDFObjectType.Text that forms the hyperlink text. The PDFDocumentPage.Hyperlinks collection gives you a quick access to all the hyperlinks of a page in one convenient location.
The PDFHyperlink structure contains these properties:
Bounds: This is the location and size on the hyperlink of the link hot spot. An external viewer may choose to change the mouse cursor shape to a "Hand" when the user hovers over this link and proceed to perform the action of the link when the user clicks link.
Hyperlink: The hyperlink string read from the PDF document. An external viewer may choose to start an external application such as a web browser when this link is clicked.
TextProperties: The hyperlink text properties such as font information and color.
using Leadtools;using Leadtools.Codecs;using Leadtools.Pdf;using Leadtools.WinForms;public void PDFDocumentPageExample(){string pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, @"Leadtools.pdf");string txtFileName = Path.Combine(LEAD_VARS.ImagesDir, @"LEAD_pdf.txt");// Open the documentusing (PDFDocument document = new PDFDocument(pdfFileName)){// Parse everything and for all pagesPDFParsePagesOptions options = PDFParsePagesOptions.All;document.ParsePages(options, 1, -1);// Save the results to the text file for examiningusing (StreamWriter writer = File.CreateText(txtFileName)){foreach (PDFDocumentPage page in document.Pages){writer.WriteLine("Page {0}", page.PageNumber);IList<PDFObject> objects = page.Objects;writer.WriteLine("Objects: {0}", objects.Count);foreach (PDFObject obj in objects){writer.WriteLine(" ObjectType: {0}", obj.ObjectType.ToString());writer.WriteLine(" Bounds: {0}, {1}, {2}, {3}", obj.Bounds.Left, obj.Bounds.Top, obj.Bounds.Right, obj.Bounds.Bottom);WriteTextProperties(writer, obj.TextProperties);writer.WriteLine(" Code: {0}", obj.Code);writer.WriteLine("------");}writer.WriteLine("---------------------");IList<PDFHyperlink> hyperlinks = page.Hyperlinks;writer.WriteLine("Hyperlinks: {0}", hyperlinks.Count);foreach (PDFHyperlink hyperlink in hyperlinks){writer.WriteLine(" Hyperlink: {0}", hyperlink.Hyperlink);writer.WriteLine(" Bounds: {0}, {1}, {2}, {3}", hyperlink.Bounds.Left, hyperlink.Bounds.Top, hyperlink.Bounds.Right, hyperlink.Bounds.Bottom);WriteTextProperties(writer, hyperlink.TextProperties);}writer.WriteLine("---------------------");}}}}private static void WriteTextProperties(StreamWriter writer, PDFTextProperties textProperties){writer.WriteLine(" TextProperties.FontHeight: {0}", textProperties.FontHeight.ToString());writer.WriteLine(" TextProperties.FontWidth: {0}", textProperties.FontWidth.ToString());writer.WriteLine(" TextProperties.FontIndex: {0}", textProperties.FontIndex.ToString());writer.WriteLine(" TextProperties.IsEndOfWord: {0}", textProperties.IsEndOfWord.ToString());writer.WriteLine(" TextProperties.IsEndOfLine: {0}", textProperties.IsEndOfLine.ToString());writer.WriteLine(" TextProperties.Color: {0}", textProperties.Color.ToString());}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";}