Class Annotation

java.lang.Object
com.datalogics.PDFL.Annotation
Direct Known Subclasses:
CircleAnnotation, FreeTextAnnotation, InkAnnotation, LineAnnotation, LinkAnnotation, PolygonAnnotation, PolyLineAnnotation, Redaction, SquareAnnotation, TextMarkupAnnotation

public class Annotation extends Object
Associates an object with its location on a page of a PDF document. An annotation associates an object such as a note, sound, or movie with a location on a page of a PDF document, or provides a way to interact with the user by means of the mouse and keyboard.

  • Constructor Details

    • Annotation

      public Annotation(Page page, String subtype, Rect initialRect)
      Create a new Annotation at the end of a page's annotation array. To create an annotation and place it elsewhere in the page's annotation array, use the version of the constructor that takes an array position.

      Parameters:
      page - The page to which the annotation is added.
      subtype - The type of the annotation.
      initialRect - A rectangle specifying the annotation's bounds, specified in user space coordinates.
    • Annotation

      public Annotation(Page page, String subtype, Rect initialRect, int addAfter)
      Create a new Annotation at a specific index in the page's annotation array.

      Parameters:
      page - The page to which the annotation is added.
      subtype - The type of the annotation.
      initialRect - A rectangle specifying the annotation's bounds, specified in user space coordinates.
      addAfter - Where to add the annotation in the page's annotation array.
  • Method Details

    • delete

      public void delete()
    • equals

      public boolean equals(Object rhs)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getTitle

      public String getTitle()
      The title of the annotation.

    • setTitle

      public void setTitle(String title)
      The title of the annotation.

    • getContents

      public String getContents()
      The text to be displayed for the annotation or, if this type of annotation does not display text, an alternate description of the annotation's contents in human-readable form.
    • setContents

      public void setContents(String arg0)
      The text to be displayed for the annotation or, if this type of annotation does not display text, an alternate description of the annotation's contents in human-readable form.
    • getColor

      public Color getColor()
      The color of the annotation.

    • setColor

      public void setColor(Color arg0)
      The color of the annotation.

    • getFlags

      public EnumSet<AnnotationFlags> getFlags()
      The flags for the annotation.

    • setFlags

      public void setFlags(EnumSet<AnnotationFlags> arg0)
      The flags for the annotation.

    • getRect

      public Rect getRect()
      The size and location of the annotation on its page

    • setRect

      public void setRect(Rect rect)
      The size and location of the annotation on its page

    • getSubtype

      public String getSubtype()
      The annotation's subtype

    • isCurrentlyVisible

      public boolean isCurrentlyVisible(OptionalContentContext occ)
      Tests whether an annotation is visible in a given optional content context, considering the current ON-OFF states of the optional-content groups in the optional-content dictionary (OCMD) and the dictionary's visibility policy.

      If the annotation occurs more than once within the content, this method only checks the visibility of the first occurrence of the annotation.

      This method determines visibility without considering the visbility of the Content object that the annotation belongs to. To determine the visibility of an annotation while taking the Content's visibility into consideration, use the alternate version of this method.

      Returns:
      true if the annotation is currently visible.
    • getNormalAppearance

      public Form getNormalAppearance()
    • setNormalAppearance

      public void setNormalAppearance(Form form)
    • generateAppearance

      public Form generateAppearance()
      Generate a new appearance stream with the current annotation properties.

      The resulting Form can then be used to set the annotation's appearance, such as by calling SetNormalAppearance.

    • getInteriorColor

      public Color getInteriorColor()
      The interior color with which to fill the annotation's line endings.

      The color of the line itself can be retrieved from Annotation.Color.

    • setInteriorColor

      public void setInteriorColor(Color color)
      The interior color with which to fill the annotation's line endings.

      Only RGB colors are allowed.

      The color of the line itself can be retrieved from Annotation.Color.

    • getAnnotationFeatureLevel

      public double getAnnotationFeatureLevel()
      The minimum PDF version necessary to support the features used in this annotation.
    • setAnnotationFeatureLevel

      public void setAnnotationFeatureLevel(double featureLevel)
      Removes features not supported in the supplied version number.
    • getPDFDict

      public PDFDict getPDFDict()
      Retrieve the PDFObject representation of this object

    • getOpacity

      public double getOpacity()
      The optional constant opacity value that shall be used in painting a Markup annotation.

      Opacity is a range from 0.0 (fully transparent) to 1.0 (fully opaque).

    • setOpacity

      public void setOpacity(double opacityValue)
      The optional constant opacity value that shall be used in painting a Markup annotation.

      Opacity is a range from 0.0 (fully transparent) to 1.0 (fully opaque).

    • getOptionalContentMembershipDict

      public OptionalContentMembershipDict getOptionalContentMembershipDict()
      The OptionalContentMembershipDict property for this Annotation.

      Setting this property will attach the Annotation to an OptionalContentMembershipDict; it will then be associated with the OptionalContentGroups and be subject to the VisibilityPolicy and VisibilityExpression of that MembershipDict.

      By setting this property to null, the Annotation is detached from any OptionalContentMembershipDict.

      Returns:
      the OptionalContentMembershipDict
    • setOptionalContentMembershipDict

      public void setOptionalContentMembershipDict(OptionalContentMembershipDict ocmd)
      The OptionalContentMembershipDict property for this Annotation.

      Setting this property will attach the Annotation to an OptionalContentMembershipDict; it will then be associated with the OptionalContentGroups and be subject to the VisibilityPolicy and VisibilityExpression of that MembershipDict.

      By setting this property to null, the Annotation is detached from any OptionalContentMembershipDict.

      Parameters:
      ocmd - the OptionalContentMembershipDict
    • hasRichTextData

      public boolean hasRichTextData()
      Checks the annotation for Rich Text String content (PDFReference 1.7 Section 8.6.2). Annotations that contain Rich Text String content and do not have a normal appearance set will not be visible when rendering the page.