Class TextAnnotation

  • All Implemented Interfaces:
    Annotation, DocumentLocation, Bounded

    public class TextAnnotation
    extends Object

    An Annotation implementation that represents a PDF annotation of type Text.

    Text annotations are 'sticky notes', snippets of commentary associated with particular location within a PDF document's page.

    The only attribute a text annotation may contain aside from those defined by the Annotation interface is the type of icon that should be displayed by a viewer to indicate the presence of a text annotation. The icon type can be retrieved using the getIconName() function.

    Version:
    ©2004-2024 Snowtide
    • Constructor Detail

      • TextAnnotation

        public TextAnnotation()
    • Method Detail

      • getIconName

        public String getIconName()
        Returns an optional String attribute indicating the type of icon to be used in displaying this annotation. The following are standard icon names:
        • Comment
        • Key
        • Note
        • Help
        • NewParagraph
        • Paragraph
        • Insert
      • getContents

        public String getContents()
        Description copied from interface: Annotation
        Returns the text content of this annotation. Some annotation types do not encode any text content; in such cases, those annotation type implementations will either return null from this function, or return an alternative descriptive text string that may be used to indicate the value or nature of this annotation.
        Specified by:
        getContents in interface Annotation
      • pageNumber

        public int pageNumber()
        Description copied from interface: DocumentLocation
        This page number is 0-indexed, and may be used to retrieve a Page object representing the page's content using the Document.getPage(int) function.

        If a page number is not available for some reason, then this method will return -1.

        Specified by:
        pageNumber in interface DocumentLocation
      • getName

        public String getName()
        Description copied from interface: Annotation
        Returns the optional name for this annotation, which should uniquely identify it within a page.
        Specified by:
        getName in interface Annotation
      • getModificationDate

        public String getModificationDate()
        Description copied from interface: Annotation
        Returns the date, in PDF date format, when this annotation was last modified. This date string may be parsed using the PDFDateParser class. This function may return null if no modification date is present in the annotation data.
        Specified by:
        getModificationDate in interface Annotation
      • getTypeCd

        public String getTypeCd()
        Description copied from interface: Annotation
        Returns a String indicating what type of annotation this this. These types are defined in Section 8.4.5 of the PDF Format Reference, and are returned with a leading forward slash.
        Specified by:
        getTypeCd in interface Annotation
      • getAppearance

        public Page getAppearance()
                           throws IOException
        Description copied from interface: Annotation
        Returns a Page containing this annotation's rendered "appearance stream", if it explicitly defines one, null otherwise. (If an annotation does not define its own appearance explicitly, it is assumed that a PDF reader / consumer will provide a default rendering based on the annotation's type and associated data.) The contents of the page can be accessed and manipulated just like any "regular" page obtained from e.g. Document.getPage(int).
        Specified by:
        getAppearance in interface Annotation
        Throws:
        IOException