←Select platform

GetAnnotations Method


Gets the annotation container of this page.

public AnnContainer GetAnnotations( 
   bool createEmpty 
Public Function GetAnnotations( 
   ByVal createEmpty As Boolean 
) As AnnContainer 
   AnnContainer^ GetAnnotations( 
      bool createEmpty 
public AnnContainer getAnnotations(boolean createEmpty) 



true to create and return an empty LEADTOOLS annotation 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

The annotation container for this page if available, or null.


Call GetAnnotations to get the annotation container of this page. All document types support this method.

SetAnnotations is used to replace the annotation container of the page. IsAnnotationsModified is used as a flag that indicates that the annotation 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, and LEADDocument.CacheOptions contains DocumentCacheOptions.PageAnnotations. 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 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. If this document uses the cache system (LEADDocument.HasCache is true), then the AnnContainer object is saved to the cache before it is returned. The 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 annotations of the document are 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 contains 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 parameter 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 annotation 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 the annotation container for the page when annotation options are used during conversions. For more information, refer to Loading Using LEADTOOLS Document Library.

Target Platforms
Help Version 21.0.2021.3.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document Assembly