Class PDAnnotationMarkup

java.lang.Object
org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation
org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup
All Implemented Interfaces:
COSObjectable
Direct Known Subclasses:
PDAnnotationFileAttachment, PDAnnotationLine, PDAnnotationRubberStamp, PDAnnotationSquareCircle, PDAnnotationText, PDAnnotationTextMarkup

public class PDAnnotationMarkup extends PDAnnotation
This class represents the additional fields of a Markup type Annotation. See section 12.5.6 of ISO32000-1:2008 (starting with page 390) for details on annotation types.
Author:
Paul King
  • Field Details

    • SUB_TYPE_FREETEXT

      public static final String SUB_TYPE_FREETEXT
      Constant for a FreeText type of annotation.
      See Also:
    • SUB_TYPE_POLYGON

      public static final String SUB_TYPE_POLYGON
      Constant for an Polygon type of annotation.
      See Also:
    • SUB_TYPE_POLYLINE

      public static final String SUB_TYPE_POLYLINE
      Constant for an PolyLine type of annotation.
      See Also:
    • SUB_TYPE_CARET

      public static final String SUB_TYPE_CARET
      Constant for an Caret type of annotation.
      See Also:
    • SUB_TYPE_INK

      public static final String SUB_TYPE_INK
      Constant for an Ink type of annotation.
      See Also:
    • SUB_TYPE_SOUND

      public static final String SUB_TYPE_SOUND
      Constant for an Sound type of annotation.
      See Also:
    • IT_FREE_TEXT

      public static final String IT_FREE_TEXT
      A plain free-text annotation, also known as a text box comment.
      See Also:
    • IT_FREE_TEXT_CALLOUT

      public static final String IT_FREE_TEXT_CALLOUT
      A callout, associated with an area on the page through the callout line specified.
      See Also:
    • IT_FREE_TEXT_TYPE_WRITER

      public static final String IT_FREE_TEXT_TYPE_WRITER
      The annotation is intended to function as a click-to-type or typewriter object.
      See Also:
    • RT_REPLY

      public static final String RT_REPLY
      Constant for an annotation reply type.
      See Also:
    • RT_GROUP

      public static final String RT_GROUP
      Constant for an annotation reply type.
      See Also:
  • Constructor Details

    • PDAnnotationMarkup

      public PDAnnotationMarkup()
      Constructor.
    • PDAnnotationMarkup

      public PDAnnotationMarkup(COSDictionary dict)
      Constructor.
      Parameters:
      dict - The annotations dictionary.
  • Method Details

    • getTitlePopup

      public String getTitlePopup()
      Retrieve the string used as the title of the popup window shown when open and active (by convention this identifies who added the annotation).
      Returns:
      The title of the popup.
    • setTitlePopup

      public void setTitlePopup(String t)
      Set the string used as the title of the popup window shown when open and active (by convention this identifies who added the annotation).
      Parameters:
      t - The title of the popup.
    • getPopup

      public PDAnnotationPopup getPopup()
      This will retrieve the popup annotation used for entering/editing the text for this annotation.
      Returns:
      the popup annotation.
    • setPopup

      public void setPopup(PDAnnotationPopup popup)
      This will set the popup annotation used for entering/editing the text for this annotation.
      Parameters:
      popup - the popup annotation.
    • getConstantOpacity

      public float getConstantOpacity()
      This will retrieve the constant opacity value used when rendering the annotation (excluing any popup).
      Returns:
      the constant opacity value.
    • setConstantOpacity

      public void setConstantOpacity(float ca)
      This will set the constant opacity value used when rendering the annotation (excluing any popup).
      Parameters:
      ca - the constant opacity value.
    • getRichContents

      public String getRichContents()
      This will retrieve the rich text stream which is displayed in the popup window.
      Returns:
      the rich text stream.
    • setRichContents

      public void setRichContents(String rc)
      This will set the rich text stream which is displayed in the popup window.
      Parameters:
      rc - the rich text stream.
    • getCreationDate

      public Calendar getCreationDate() throws IOException
      This will retrieve the date and time the annotation was created.
      Returns:
      the creation date/time.
      Throws:
      IOException - if there is a format problem when converting the date.
    • setCreationDate

      public void setCreationDate(Calendar creationDate)
      This will set the date and time the annotation was created.
      Parameters:
      creationDate - the date and time the annotation was created.
    • getInReplyTo

      public PDAnnotation getInReplyTo() throws IOException
      This will retrieve the annotation to which this one is "In Reply To" the actual relationship is specified by the RT entry.
      Returns:
      the other annotation or null if there is none.
      Throws:
      IOException - if there is an error creating the other annotation.
    • setInReplyTo

      public void setInReplyTo(PDAnnotation irt)
      This will set the annotation to which this one is "In Reply To" the actual relationship is specified by the RT entry.
      Parameters:
      irt - the annotation this one is "In Reply To".
    • getSubject

      public String getSubject()
      This will retrieve the short description of the subject of the annotation.
      Returns:
      the subject.
    • setSubject

      public void setSubject(String subj)
      This will set the short description of the subject of the annotation.
      Parameters:
      subj - short description of the subject.
    • getReplyType

      public String getReplyType()
      This will retrieve the Reply Type (relationship) with the annotation in the IRT entry See the RT_* constants for the available values.
      Returns:
      the relationship.
    • setReplyType

      public void setReplyType(String rt)
      This will set the Reply Type (relationship) with the annotation in the IRT entry See the RT_* constants for the available values.
      Parameters:
      rt - the reply type.
    • getIntent

      public String getIntent()
      This will retrieve the intent of the annotation The values and meanings are specific to the actual annotation See the IT_* constants for the annotation classes.
      Returns:
      the intent
    • setIntent

      public void setIntent(String it)
      This will set the intent of the annotation The values and meanings are specific to the actual annotation See the IT_* constants for the annotation classes.
      Parameters:
      it - the intent
    • getExternalData

      public PDExternalDataDictionary getExternalData()
      This will return the external data dictionary.
      Returns:
      the external data dictionary
    • setExternalData

      public void setExternalData(PDExternalDataDictionary externalData)
      This will set the external data dictionary.
      Parameters:
      externalData - the external data dictionary
    • setBorderStyle

      public void setBorderStyle(PDBorderStyleDictionary bs)
      This will set the border style dictionary, specifying the width and dash pattern used in drawing the line.
      Parameters:
      bs - the border style dictionary to set.
    • getBorderStyle

      public PDBorderStyleDictionary getBorderStyle()
      This will retrieve the border style dictionary, specifying the width and dash pattern used in drawing the line.
      Returns:
      the border style dictionary.
    • setLineEndingStyle

      public final void setLineEndingStyle(String style)
      This will set the line ending style.
      Parameters:
      style - The new style.
    • getLineEndingStyle

      public String getLineEndingStyle()
      This will retrieve the line ending style.
      Returns:
      The line ending style, possible values shown in the LE_ constants section, LE_NONE if missing, never null.
    • setInteriorColor

      public void setInteriorColor(PDColor ic)
      This will set interior color.
      Parameters:
      ic - color.
    • getInteriorColor

      public PDColor getInteriorColor()
      This will retrieve the interior color.
      Returns:
      object representing the color.
    • setBorderEffect

      public void setBorderEffect(PDBorderEffectDictionary be)
      This will set the border effect dictionary, specifying effects to be applied when drawing the line. This is supported by PDF 1.5 and higher.
      Parameters:
      be - The border effect dictionary to set.
    • getBorderEffect

      public PDBorderEffectDictionary getBorderEffect()
      This will retrieve the border effect dictionary, specifying effects to be applied used in drawing the line.
      Returns:
      The border effect dictionary
    • setInkList

      public void setInkList(float[][] inkList)
      Sets the paths that make this annotation.
      Parameters:
      inkList - An array of arrays, each representing a stroked path. Each array shall be a series of alternating horizontal and vertical coordinates. If the parameter is null the entry will be removed.
    • getInkList

      public float[][] getInkList()
      Get one or more disjoint paths that make this annotation.
      Returns:
      An array of arrays, each representing a stroked path. Each array shall be a series of alternating horizontal and vertical coordinates.
    • getDefaultAppearance

      public String getDefaultAppearance()
      Get the default appearance.
      Returns:
      a string describing the default appearance.
    • setDefaultAppearance

      public void setDefaultAppearance(String daValue)
      Set the default appearance.
      Parameters:
      daValue - a string describing the default appearance.
    • getDefaultStyleString

      public String getDefaultStyleString()
      Get the default style string. The default style string defines the default style for rich text fields.
      Returns:
      the DS element of the dictionary object
    • setDefaultStyleString

      public void setDefaultStyleString(String defaultStyleString)
      Set the default style string. Providing null as the value will remove the default style string.
      Parameters:
      defaultStyleString - a string describing the default style.
    • getQ

      public int getQ()
      This will get the 'quadding' or justification of the text to be displayed.
      0 - Left (default)
      1 - Centered
      2 - Right
      Please see the QUADDING_CONSTANTS in PDVariableText.
      Returns:
      The justification of the text strings.
    • setQ

      public void setQ(int q)
      This will set the quadding/justification of the text. Please see the QUADDING_CONSTANTS in PDVariableText.
      Parameters:
      q - The new text justification.
    • setRectDifference

      public void setRectDifference(PDRectangle rd)
      This will set the rectangle difference rectangle. Giving the difference between the annotations rectangle and where the drawing occurs. (To take account of any effects applied through the BE entry for example)
      Parameters:
      rd - the rectangle difference
    • getRectDifference

      public PDRectangle getRectDifference()
      This will get the rectangle difference rectangle. Giving the difference between the annotations rectangle and where the drawing occurs. (To take account of any effects applied through the BE entry for example)
      Returns:
      the rectangle difference
    • setRectDifferences

      public void setRectDifferences(float difference)
      This will set the difference between the annotations "outer" rectangle defined by /Rect and boundaries of the underlying.

      This will set an equal difference for all sides

      Parameters:
      difference - from the annotations /Rect entry
    • setRectDifferences

      public void setRectDifferences(float differenceLeft, float differenceTop, float differenceRight, float differenceBottom)
      This will set the difference between the annotations "outer" rectangle defined by /Rect and the border.
      Parameters:
      differenceLeft - left difference from the annotations /Rect entry
      differenceTop - top difference from the annotations /Rect entry
      differenceRight - right difference from the annotations /Rect entry
      differenceBottom - bottom difference from the annotations /Rect entry
    • getRectDifferences

      public float[] getRectDifferences()
      This will get the margin between the annotations "outer" rectangle defined by /Rect and the boundaries of the underlying caret.
      Returns:
      the differences. If the entry hasn't been set am empty array is returned.
    • setCallout

      public final void setCallout(float[] callout)
      This will set the coordinates of the callout line. (PDF 1.6 and higher) Only relevant if the intent is FreeTextCallout.
      Parameters:
      callout - An array of four or six numbers specifying a callout line attached to the free text annotation. Six numbers [ x1 y1 x2 y2 x3 y3 ] represent the starting, knee point, and ending coordinates of the line in default user space, four numbers [ x1 y1 x2 y2 ] represent the starting and ending coordinates of the line.
    • getCallout

      public float[] getCallout()
      This will get the coordinates of the callout line. (PDF 1.6 and higher) Only relevant if the intent is FreeTextCallout.
      Returns:
      An array of four or six numbers specifying a callout line attached to the free text annotation. Six numbers [ x1 y1 x2 y2 x3 y3 ] represent the starting, knee point, and ending coordinates of the line in default user space, four numbers [ x1 y1 x2 y2 ] represent the starting and ending coordinates of the line.
    • setStartPointEndingStyle

      public void setStartPointEndingStyle(String style)
      This will set the line ending style for the start point, see the LE_ constants for the possible values.
      Parameters:
      style - The new style.
    • getStartPointEndingStyle

      public String getStartPointEndingStyle()
      This will retrieve the line ending style for the start point, possible values shown in the LE_ constants section.
      Returns:
      The ending style for the start point, LE_NONE if missing, never null.
    • setEndPointEndingStyle

      public void setEndPointEndingStyle(String style)
      This will set the line ending style for the end point, see the LE_ constants for the possible values.
      Parameters:
      style - The new style.
    • getEndPointEndingStyle

      public String getEndPointEndingStyle()
      This will retrieve the line ending style for the end point, possible values shown in the LE_ constants section.
      Returns:
      The ending style for the end point, LE_NONE if missing, never null.
    • getVertices

      public float[] getVertices()
      This will retrieve the numbers that shall represent the alternating horizontal and vertical coordinates.
      Returns:
      An array of floats representing the alternating horizontal and vertical coordinates.
    • setVertices

      public void setVertices(float[] points)
      This will set the numbers that shall represent the alternating horizontal and vertical coordinates.
      Parameters:
      points - an array with the numbers that shall represent the alternating horizontal and vertical coordinates.
    • getPath

      public float[][] getPath()
      PDF 2.0: This will retrieve the arrays that shall represent the alternating horizontal and vertical coordinates for path building.
      Returns:
      An array of float arrays, each supplying the operands for a path building operator (m, l or c). The first array should have 2 elements, the others should have 2 or 6 elements.
    • setCustomAppearanceHandler

      public void setCustomAppearanceHandler(PDAppearanceHandler appearanceHandler)
      Set a custom appearance handler for generating the annotations appearance streams.
      Parameters:
      appearanceHandler -
    • constructAppearances

      public void constructAppearances()
      Description copied from class: PDAnnotation
      Create the appearance entry for this annotation. Not having it may prevent display in some viewers. This method is for overriding in subclasses, the default implementation does nothing.
      Overrides:
      constructAppearances in class PDAnnotation
    • constructAppearances

      public void constructAppearances(PDDocument document)
      Description copied from class: PDAnnotation
      Create the appearance entry for this annotation. Not having it may prevent display in some viewers. This method is for overriding in subclasses, the default implementation does nothing.
      Overrides:
      constructAppearances in class PDAnnotation
      Parameters:
      document -