Holds the properties of a link inside the document.
[SerializableAttribute()][DataContractAttribute()]public struct DocumentLink
public [SerializableAttribute,DataContractAttribute]value class DocumentLink sealed
public class DocumentLink implements Serializable class DocumentLink: The links of a document page can be get and set using GetLinks and SetLinks and contain the following members:
| Member | Description |
|---|---|
|
The location and size of the link in the page. |
|
|
Type of the link target: An internal position in the same document or an external value (hyperlink) |
|
|
The target in the document if this is an internal link |
|
|
The value (hyperlink) if this is an external link that can automatically be parsed using the regular expressions stored in DocumentText.LinkPatterns. |
using Leadtools;using Leadtools.Codecs;using Leadtools.Document.Writer;using Leadtools.Document;using Leadtools.Caching;using Leadtools.Annotations.Engine;using Leadtools.Ocr;using Leadtools.Barcode;using Leadtools.Document.Converter;public void DocumentPageGetLinksExample(){var cache = GetCache();var options = new LoadDocumentOptions();options.Cache = cache;using (var document = DocumentFactory.LoadFromFile(Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.pdf"), options)){document.IsReadOnly = false;// Show the links before parsing the URL in the textConsole.WriteLine("Before get text");Console.WriteLine("---------");var page = document.Pages[0];page.SetLinks(page.GetLinks());ShowLinks(page);// Get all of the DocumentPageFitTypesDocumentPageFitType[] pageFitType = (DocumentPageFitType[])Enum.GetValues(typeof(DocumentPageFitType));foreach (var type in pageFitType){Console.WriteLine($"Page fit type: {type}");}// Make sure we will parse the hyper links// DocumentText referencedocument.Text.AutoParseLinks = true;document.Text.TextExtractionMode = DocumentTextExtractionMode.Auto;// Show the regular expressionsConsole.WriteLine("Parsing links from the text using these regular expressions:");foreach (var regex in DocumentText.LinkPatterns){Console.WriteLine(regex.ToString());}// Now, get the text to parse the links from itpage.GetText();page.IsLinksModified = false;// Show the links before parsing the URL in the text. It should now show the original plus any parsed URLs from the textConsole.WriteLine("After get text");Console.WriteLine("---------");ShowLinks(page);}}private static void ShowLinks(Leadtools.Document.DocumentPage page){// DocumentLink referencevar links = page.GetLinks();if (links != null){int index = 0;Console.WriteLine("Page " + page.PageNumber);foreach (var link in links){Console.WriteLine(index++);Console.WriteLine(" Bounds:" + link.Bounds);Console.WriteLine(" LinkType:" + link.LinkType);if (link.LinkType == DocumentLinkType.Value){Console.WriteLine(" Value:" + link.Value);}else{// DocumentLinkTarget referenceConsole.WriteLine(" Target.PageFitType:" + link.Target.PageFitType);Console.WriteLine(" Target.PageNumber:" + link.Target.PageNumber);Console.WriteLine(" Target.Position:" + link.Target.Position);Console.WriteLine(" Target.ZoomPercent:" + link.Target.ZoomPercent);}Console.WriteLine();}}}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
