←Select platform

InternalLinks Property

Summary
Gets the internal links (or jumps) between the pages of this PDF document.
Syntax
C#
C++/CLI
Java
Python
public IList<PDFInternalLink> InternalLinks { get; } 
public java.util.List<PDFInternalLink> getInternalLinks(); 
public: 
property IList<PDFInternalLink>^ InternalLinks { 
   IList<PDFInternalLink>^ get(); 
} 
InternalLinks # get  (PDFDocument) 

Property Value

A list of PDFInternalLink objects that specify the internal links (or jumps) between the pages of this PDFDocument. The default value is null.

Remarks

Use ParseDocumentStructure to parse the document structure of the PDF document. The document structure is the Table of Contents (TOC) represented by a list of PDF bookmark objects stored in the Bookmarks property and the internal links between pages (or jumps) found in the document stored in the InternalLinks property.

When you first create an instance of PDFDocument, both InternalLinks and Bookmarks will be initialized to null . You must call ParseDocumentStructure with the desired PDFParseDocumentStructureOptions passed to the options parameters. When this method returns, the InternalLinks and Bookmarks will be populated accordingly.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Controls; 
using Leadtools.Pdf; 
using Leadtools.Svg; 
using Leadtools.WinForms; 
 
 
public void PDFDocumentParseDocumentStructureExample() 
{ 
   string pdfFileName1 = Path.Combine(LEAD_VARS.ImagesDir, @"Leadtools.pdf"); 
   string pdfFileName2 = Path.Combine(LEAD_VARS.ImagesDir, @"Bookmarks.pdf"); 
 
   // Create a version of the source file with a few bookmarks 
   PDFFile file = new PDFFile(pdfFileName1); 
   // Load the pages 
   file.Load(); 
   List<PDFBookmark> bookmarks = new List<PDFBookmark>(); 
 
   // We will bookmarks for each page, cascading levels: 
   // Goto page 1 
   //    Goto page 2 
   //       Goto page 3 
   //          Goto page 4 
   int level = 0; 
   for (int i = 0; i < file.Pages.Count; i++) 
   { 
      PDFFilePage page = file.Pages[i]; 
 
      PDFBookmark bookmark = new PDFBookmark(); 
      bookmark.Title = "Goto page " + page.PageNumber.ToString(); 
      bookmark.BookmarkStyle = PDFBookmarkStyle.Plain; 
      bookmark.Level = level; 
      bookmark.TargetPageNumber = page.PageNumber; 
      bookmark.TargetPageFitType = PDFPageFitType.Default; 
      bookmark.TargetPosition = new PDFPoint(0, page.Height); 
      bookmark.TargetZoomPercent = 0; 
      bookmarks.Add(bookmark); 
 
      level++; 
      if (level > 8) 
      { 
         // Reset levels 
         level = 0; 
      } 
   } 
 
   file.WriteBookmarks(bookmarks, pdfFileName2); 
 
   // Create a document for the output file 
   using (PDFDocument document = new PDFDocument(pdfFileName2)) 
   { 
      // Now read the bookmarks and internal links in the document 
      document.ParseDocumentStructure(PDFParseDocumentStructureOptions.InternalLinks | PDFParseDocumentStructureOptions.Bookmarks); 
 
      Console.WriteLine("{0} bookmarks found:", document.Bookmarks.Count); 
      foreach (PDFBookmark bookmark in document.Bookmarks) 
      { 
         Console.WriteLine(" Title: {0}, Level: {1}, Target page: {2}", bookmark.Title, bookmark.Level, bookmark.TargetPageNumber); 
      } 
 
      Console.WriteLine("{0} Internal links found:", document.InternalLinks.Count); 
      foreach (PDFInternalLink internalLink in document.InternalLinks) 
      { 
         Console.WriteLine(" Source bounds: {0}, Target page: {1}", internalLink.SourceBounds, internalLink.TargetPageNumber); 
      } 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.7.10
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Pdf Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.