Class PdfAnnotation

Direct Known Subclasses:
PdfFormField

public class PdfAnnotation extends PdfDictionary
A PdfAnnotation is a note that is associated with a page.
See Also:
  • Field Details

    • HIGHLIGHT_INVERT

      static final PdfName HIGHLIGHT_INVERT
      highlight attributename
    • HIGHLIGHT_TOGGLE

      static final PdfName HIGHLIGHT_TOGGLE
      highlight attributename
    • FLAGS_HIDDEN

      static final int FLAGS_HIDDEN
      flagvalue
      See Also:
    • FLAGS_PRINT

      public static final int FLAGS_PRINT
      flagvalue
      See Also:
    • FLAGS_NOVIEW

      static final int FLAGS_NOVIEW
      flagvalue
      See Also:
    • FLAGS_LOCKED

      static final int FLAGS_LOCKED
      flagvalue
      See Also:
    • APPEARANCE_NORMAL

      static final PdfName APPEARANCE_NORMAL
      appearance attributename
    • MARKUP_UNDERLINE

      private static final int MARKUP_UNDERLINE
      attributevalue
      See Also:
    • MARKUP_STRIKEOUT

      private static final int MARKUP_STRIKEOUT
      attributevalue
      See Also:
    • MARKUP_SQUIGGLY

      private static final int MARKUP_SQUIGGLY
      attributevalue
      Since:
      2.1.3
      See Also:
    • writer

      protected PdfWriter writer
    • reference

      private PdfIndirectReference reference
      Reference to this annotation.
      Since:
      2.1.6; was removed in 2.1.5, but restored in 2.1.6
    • templates

      protected HashMap templates
    • form

      protected boolean form
    • annotation

      protected boolean annotation
    • used

      protected boolean used
      Holds value of property used.
    • placeInPage

      private int placeInPage
      Holds value of property placeInPage.
  • Constructor Details

    • PdfAnnotation

      PdfAnnotation(PdfWriter writer, Rectangle rect)
    • PdfAnnotation

      public PdfAnnotation(PdfWriter writer, float llx, float lly, float urx, float ury, PdfString title, PdfString content)
      Constructs a new PdfAnnotation of subtype text.
      Parameters:
      writer - writer to put
      llx - position llx to put
      lly - position lly to put
      urx - position urx to put
      ury - position ury to put
      title - title to put
      content - content to put
    • PdfAnnotation

      public PdfAnnotation(PdfWriter writer, float llx, float lly, float urx, float ury, PdfAction action)
      Constructs a new PdfAnnotation of subtype link (Action).
      Parameters:
      writer - writer to put
      llx - position llx to put
      lly - position lly to put
      urx - position urx to put
      ury - position ury to put
      action - action to put
  • Method Details

    • createScreen

      public static PdfAnnotation createScreen(PdfWriter writer, Rectangle rect, String clipTitle, PdfFileSpecification fs, String mimeType, boolean playOnDisplay) throws IOException
      Creates a screen PdfAnnotation
      Parameters:
      writer - Writer to create
      rect - Rectangle to create
      clipTitle - Cliptitle to create
      fs - FileSpecification to create
      mimeType - Mimetype to set
      playOnDisplay - PlayOnDisplay to set
      Returns:
      a screen PdfAnnotation
      Throws:
      IOException - Exception of a I/O
    • getIndirectReference

      public PdfIndirectReference getIndirectReference()
      Returns an indirect reference to the annotation
      Returns:
      the indirect reference
    • createLink

      private static PdfAnnotation createLink(PdfWriter writer, Rectangle rect, PdfName highlight)
      Creates a link.
      Parameters:
      writer -
      rect -
      highlight -
      Returns:
      A PdfAnnotation
    • createFileAttachment

      private static PdfAnnotation createFileAttachment(PdfWriter writer, Rectangle rect, String contents, PdfFileSpecification fs) throws IOException
      Creates a file attachment annotation
      Parameters:
      writer -
      rect -
      contents -
      fs -
      Returns:
      the annotation
      Throws:
      IOException
    • setDefaultAppearanceString

      public void setDefaultAppearanceString(PdfContentByte cb)
    • setFlags

      public void setFlags(int flags)
    • setBorder

      public void setBorder(PdfBorderArray border)
    • setBorderStyle

      public void setBorderStyle(PdfBorderDictionary border)
    • setHighlighting

      public void setHighlighting(PdfName highlight)
      Sets the annotation's highlighting mode. The values can be HIGHLIGHT_NONE, HIGHLIGHT_INVERT, HIGHLIGHT_OUTLINE and HIGHLIGHT_PUSH;
      Parameters:
      highlight - the annotation's highlighting mode
    • setAppearance

      void setAppearance(PdfName ap, PdfTemplate template)
    • setAppearance

      void setAppearance(PdfName ap, String state, PdfTemplate template)
    • setAppearanceState

      public void setAppearanceState(String state)
    • setColor

      public void setColor(Color color)
    • setTitle

      public void setTitle(String title)
    • setPopup

      public void setPopup(PdfAnnotation popup)
    • setAction

      public void setAction(PdfAction action)
    • isUsed

      public boolean isUsed()
      Getter for property used.
      Returns:
      Value of property used.
    • setUsed

      public void setUsed()
      Setter for property used.
    • getTemplates

      public HashMap getTemplates()
    • isForm

      public boolean isForm()
      Getter for property form.
      Returns:
      Value of property form.
    • isAnnotation

      public boolean isAnnotation()
      Getter for property annotation.
      Returns:
      Value of property annotation.
    • setPage

      public void setPage(int page)
    • setPage

      void setPage()
    • getPlaceInPage

      public int getPlaceInPage()
      Getter for property placeInPage.
      Returns:
      Value of property placeInPage.
    • setPlaceInPage

      public void setPlaceInPage(int placeInPage)
      Places the annotation in a specified page that must be greater or equal to the current one. With PdfStamper the page can be any. The first page is 1.
      Parameters:
      placeInPage - New value of property placeInPage.
    • setRotate

      public void setRotate(int v)
    • getMK

      private PdfDictionary getMK()
    • setMKRotation

      public void setMKRotation(int rotation)
    • getMKColor

      static PdfArray getMKColor(Color color)
    • setMKBorderColor

      public void setMKBorderColor(Color color)
    • setMKBackgroundColor

      public void setMKBackgroundColor(Color color)
    • setMKNormalCaption

      public void setMKNormalCaption(String caption)
    • setMKRolloverCaption

      public void setMKRolloverCaption(String caption)
    • setMKAlternateCaption

      public void setMKAlternateCaption(String caption)
    • setMKNormalIcon

      public void setMKNormalIcon(PdfTemplate template)
    • setMKRolloverIcon

      public void setMKRolloverIcon(PdfTemplate template)
    • setMKAlternateIcon

      public void setMKAlternateIcon(PdfTemplate template)
    • setMKIconFit

      void setMKIconFit(PdfName scale, PdfName scalingType, float leftoverLeft, float leftoverBottom, boolean fitInBounds)
    • setMKTextPosition

      public void setMKTextPosition(int tp)
    • setLayer

      public void setLayer(PdfOCG layer)
      Sets the layer this annotation belongs to.
      Parameters:
      layer - the layer this annotation belongs to
    • setName

      public void setName(String name)
      Sets the name of the annotation. With this name the annotation can be identified among all the annotations on a page (it has to be unique).
      Parameters:
      name - name to set