getAnnotations Method

Summary

Gets the annotations container of this page.

Syntax
TypeScript
JavaScript
DocumentPage.prototype.getAnnotations = function( 
   createEmpty 
) 
getAnnotations( 
   createEmpty: boolean 
): JQueryPromise<AnnContainer>; 

Parameters

createEmpty

true to create and return an empty LEADTOOLS annotations container if the page does not have one originally, otherwise;

false to return null if the page does not have an original container.

Return Value

A Promise object that may resolve successfully to an object of type AnnContainer for this page, or null.

Remarks

GetAnnotations is used to get the annotations container of this page. All document types support this method.

SetAnnotations is used to replace the annotation container of the page. IsAnnotationsModified is used to as flag that indicates that the annotations container of this page has been replaced by the user.

This method works as follows (the "item" is an annotation container):

  1. If an item was found in the cache, it is returned right away. This is available if the document was created using the cache system. AnnCodecs is used to load the AnnContainer object from the data found in the cache.

  2. If this is an original page in the source document file (the value of OriginalPageNumber is not -1), then the annotation is container is loaded from the original document. See below for more information.

  3. If this is not an original page in the source document file (the value of OriginalPageNumber is not 1), then depending on the value of createEmpty a new AnnContainer object is created based on the page size and resolution or null is used.

  4. The AnnContainer object is saved to the cache before it is returned. Next time this method is called, the container will be returned from the cache directly without loading it from the file or creating a new instance.

Note that if SetAnnotations has been previously called with a null object for the container parameter, then this method will return null as well.

In all cases, the returned AnnContainer object is not used by this LEADDocument, the user is responsible for deleting it after it has been used.

The original annotation of the document is obtained in one of two ways:

  • If the user passed the location of an external LEADTOOLS annotations file to use with the document using LoadDocumentOptions.AnnotationsUri, then this file is checked against OriginalPageNumber and if an item is found, it is loaded and used by this method.

  • If this document type supports embedded annotations (such as PDF or TIFF documents) and the user set the value of LoadDocumentOptions.LoadEmbeddedAnnotations to true, then this method will try to load the annotations from the document file itself if found. The value of HasEmbeddedAnnotations will be true if the original document file contain an annotation container for this page.

In either case, if the original document or annotation file did not have an annotation container for this page, the createEmpty will be used to either return null or create an empty container for the page. Note that you can use DocumentAnnotations.GetAnnotations and DocumentAnnotations.SetAnnotations to get or set an array of annotations container objects for one or more pages with a single call. The LEADTOOLS Document Viewer uses this method to obtain the annotation container for the page when. The LEADTOOLS Document Converter uses this method to obtain annotation container for the page when annotations options are used during conversions. Refer to Loading Using LEADTOOLS Document Library for more information.

Requirements

Target Platforms

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

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