Class WritableAnnotation

java.lang.Object
org.jpedal.io.annotation.WritableAnnotation
Direct Known Subclasses:
CircleAnnotation, FreeTextAnnotation, HighlightAnnotation, ImageAnnotation, InkAnnotation, LineAnnotation, LinkAnnotation, PolygonAnnotation, PolyLineAnnotation, SquareAnnotation, TextAnnotation

public class WritableAnnotation extends Object
Interface for creating annotations
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Annotation types, each written as the matching PDF annotation /Subtype.
  • Method Summary

    Modifier and Type
    Method
    Description
    getAPString(int parentObj)
    Returns the appearance stream object to write for this annotation.
     
    Returns the form object used to create this object or null is none were used.
    float[]
    Returns the annotation's interior colour as RGB components from 0 to 1.
    int
    Returns the page the annotation is added to.
    getPopupString(int parentObj)
    Returns the dictionary of a popup annotation to write with this annotation.
    byte[][]
    getResources(int parentObj)
    Returns any extra objects, such as images, that this annotation's appearance needs.
    float[]
    Returns the annotation's colour as RGB components from 0 to 1.
    void
    Sets the annotation's interior colour, written as its /IC entry by annotation types that support one.
    void
    Sets the annotation's colour, written as its /C entry by annotation types that support one.
    void
    setTextSize(int textSize)
    Sets the font size of the annotation's text.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getPage

      public int getPage()
      Returns the page the annotation is added to.
      Returns:
      the page number, starting from 0
    • setTextSize

      public void setTextSize(int textSize)
      Sets the font size of the annotation's text. Currently only FreeTextAnnotation uses it. Default value is 10.
      Parameters:
      textSize - font size in points
    • setStrokeColor

      public void setStrokeColor(Color color)
      Sets the annotation's colour, written as its /C entry by annotation types that support one. The alpha of the colour is ignored. The default depends on the annotation type.
      Parameters:
      color - the colour to use
    • setNonStrokeColor

      public void setNonStrokeColor(Color color)
      Sets the annotation's interior colour, written as its /IC entry by annotation types that support one. The alpha of the colour is ignored. Most annotation types default to no interior colour.
      Parameters:
      color - the colour to use
    • getStrokeColor

      public float[] getStrokeColor()
      Returns the annotation's colour as RGB components from 0 to 1.
      Returns:
      the colour array used by this annotation (not a copy)
    • getNonStrokeColor

      public float[] getNonStrokeColor()
      Returns the annotation's interior colour as RGB components from 0 to 1.
      Returns:
      the colour array used by this annotation (not a copy), or null if it has no interior colour
    • getFormObject

      public FormObject getFormObject()
      Returns the form object used to create this object or null is none were used.
      Returns:
      FormObject which encapsulates all form data (accessible from getters and setters)
    • getDictString

      public String getDictString()
      Returns:
      Pdf specified dictionary string
    • getPopupString

      public String getPopupString(int parentObj)
      Returns the dictionary of a popup annotation to write with this annotation. This implementation logs that popups are not supported for this annotation type and returns null.
      Parameters:
      parentObj - object number of this annotation's dictionary
      Returns:
      Pdf specified popup dictionary string, or null if there is no popup
    • getAPString

      public String getAPString(int parentObj)
      Returns the appearance stream object to write for this annotation. Subclasses that have one reference it from getDictString(), so this must be called first. This implementation records the object number and returns null.
      Parameters:
      parentObj - object number the appearance stream will be written as
      Returns:
      Pdf specified appearance stream object string, or null if there is none
    • getResources

      public byte[][] getResources(int parentObj)
      Returns any extra objects, such as images, that this annotation's appearance needs. They are written before the appearance stream, one object number each. This implementation records the object number and returns an empty array.
      Parameters:
      parentObj - object number the first resource will be written as
      Returns:
      the resource objects to write, which may be empty