DocumentStructure Object


Manages the structure of the document.


JavaScript Syntax
function lt.Documents.DocumentStructure 
TypeScript Syntax
class lt.Documents.DocumentStructure() 


DocumentStructure manages the structure of the document. This includes the bookmarks that represents the table of content. It can be accessed through the Structure property of Document.

Not all document types contain support for document structure. For these types of documents (such as TIF file or Text document), the value of IsStructureSupported of Document will be false and the Structure is null and should not be used. The rest of the discussion of this section is related to when IsStructureSupported is true.

When the structure is supported (for example, PDF documents), the value of IsStructureSupported is true and Structure is a valid object can be used.

Loading the document structure can take some time, therefore, it is not read automatically when a new Document is created from a disk or URL document. This is done so that the document is loaded as quick as possible and to not make the user wait if the bookmarks or table of content is not needed in your application.

To parse the document for bookmarks and table of content, use the Parse method while the value of ParseBookmarks is true (the default value). Usually you can call this method once after the Document is loaded. The IsParsed property can be used to check if the structure has been parsed.

If Parse is not called or the value of ParseBookmarks is false, then Bookmarks is an empty list.

When Parse is called and ParseBookmarks is true (the default value), the Bookmarks list will be updated with all the bookmarks and table of content items found in the original document. You can then read and modify these bookmarks if needed. If the value of ParseBookmarks is set to false, then Parse will not try to parse the bookmarks in the document.

Parse will also parse the document for any links found in the pages if the value of ParsePageLinks is true (the default value), these links can be obtain through the DocumentPage.GetLinks method. If the value of ParsePageLinks is set to false, then Parse will not try to parse the links found in the pages.

Setting ParseBookmarks or ParsePageLinks to false can help with increasing the speed of the Parse method if the user is not interested in one or the other.


This example shows how to parse the structure (bookmarks) of a PDF document.

Start with the example in Document and replace the example function call to the function below.

JavaScript Example
function documentStructureExample() { 
   // Load a new document 
   var url = ""; 
   console.log("Loading document ..."); 
   lt.Documents.DocumentFactory.loadFromUri(url, null) 
       .done(function (doc) { 
          console.log("Done. Showing the structure ..."); 
function showBookmark(bookmark, indent) { 
   console.log(indent + "page:" + + " title '" + bookmark.title + "'"); 
   for (var i = 0; i < bookmark.children.length; i++) { 
      showBookmark(bookmark.children[i], indent + "  "); 
function showStructure(doc) { 
   if (!doc.isStructureSupported) { 
      // This document does not support table of content or links 
   if (doc.structure.isParsed) { 
      // Show them 
      var bookmarks = doc.structure.bookmarks; 
      for (var i = 0; i < bookmarks.length; i++) { 
         this.showBookmark(bookmarks[i], ""); 
   else { 
      // We support it, but we dont have it parsed yet, do it now 
          .done(function (doc) { 
             console.log("Document structure was parsed succesfully"); 
             // Show the structure, this time doc.isStructureParsed is true and will not call 
             // the command again 


Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Documents Assembly