Class PdfAnnotation

    • Field Detail

      • HIGHLIGHT_NONE

        public static final PdfName HIGHLIGHT_NONE
        highlight attributename
      • HIGHLIGHT_INVERT

        public static final PdfName HIGHLIGHT_INVERT
        highlight attributename
      • HIGHLIGHT_OUTLINE

        public static final PdfName HIGHLIGHT_OUTLINE
        highlight attributename
      • HIGHLIGHT_PUSH

        public static final PdfName HIGHLIGHT_PUSH
        highlight attributename
      • HIGHLIGHT_TOGGLE

        public static final PdfName HIGHLIGHT_TOGGLE
        highlight attributename
      • FLAGS_TOGGLENOVIEW

        public static final int FLAGS_TOGGLENOVIEW
        flagvalue
        See Also:
        Constant Field Values
      • APPEARANCE_NORMAL

        public static final PdfName APPEARANCE_NORMAL
        appearance attributename
      • APPEARANCE_ROLLOVER

        public static final PdfName APPEARANCE_ROLLOVER
        appearance attributename
      • APPEARANCE_DOWN

        public static final PdfName APPEARANCE_DOWN
        appearance attributename
      • AA_ENTER

        public static final PdfName AA_ENTER
        attributevalue
      • AA_EXIT

        public static final PdfName AA_EXIT
        attributevalue
      • AA_DOWN

        public static final PdfName AA_DOWN
        attributevalue
      • AA_UP

        public static final PdfName AA_UP
        attributevalue
      • AA_FOCUS

        public static final PdfName AA_FOCUS
        attributevalue
      • AA_BLUR

        public static final PdfName AA_BLUR
        attributevalue
      • AA_JS_KEY

        public static final PdfName AA_JS_KEY
        attributevalue
      • AA_JS_FORMAT

        public static final PdfName AA_JS_FORMAT
        attributevalue
      • AA_JS_CHANGE

        public static final PdfName AA_JS_CHANGE
        attributevalue
      • AA_JS_OTHER_CHANGE

        public static final PdfName AA_JS_OTHER_CHANGE
        attributevalue
      • MARKUP_HIGHLIGHT

        public static final int MARKUP_HIGHLIGHT
        attributevalue
        See Also:
        Constant Field Values
      • MARKUP_UNDERLINE

        public static final int MARKUP_UNDERLINE
        attributevalue
        See Also:
        Constant Field Values
      • MARKUP_STRIKEOUT

        public static final int MARKUP_STRIKEOUT
        attributevalue
        See Also:
        Constant Field Values
      • MARKUP_SQUIGGLY

        public static final int MARKUP_SQUIGGLY
        attributevalue
        Since:
        2.1.3
        See Also:
        Constant Field Values
      • reference

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

        protected java.util.Map<PdfTemplate,​java.lang.Object> 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 Detail

      • 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 - pdf writer
        llx - lower-left-x
        lly - lower-left-y
        urx - upper-right-x
        ury - upper-right-y
        title - title
        content - content
      • 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 - pdf writer
        llx - lower-left-x
        lly - lower-left-y
        urx - upper-right-x
        ury - upper-right-y
        action - PdfAction
    • Method Detail

      • createScreen

        public static PdfAnnotation createScreen​(PdfWriter writer,
                                                 Rectangle rect,
                                                 java.lang.String clipTitle,
                                                 PdfFileSpecification fs,
                                                 java.lang.String mimeType,
                                                 boolean playOnDisplay)
                                          throws java.io.IOException
        Creates a screen PdfAnnotation
        Parameters:
        writer - PdfWriter
        rect - dimensions Rectangle
        clipTitle - clip title
        fs - PdfFileSpecification
        mimeType - mime type of the file
        playOnDisplay - play on display
        Returns:
        a screen PdfAnnotation
        Throws:
        java.io.IOException - on error
      • createText

        public static PdfAnnotation createText​(PdfWriter writer,
                                               Rectangle rect,
                                               java.lang.String title,
                                               java.lang.String contents,
                                               boolean open,
                                               java.lang.String icon)
        Parameters:
        writer - PdfWriter
        rect - dimensions Rectangle
        title - title for the link
        contents - content
        open - open
        icon - icon
        Returns:
        a PdfAnnotation
      • createLink

        public static PdfAnnotation createLink​(PdfWriter writer,
                                               Rectangle rect,
                                               PdfName highlight,
                                               java.lang.String namedDestination)
        Creates an Annotation with an local destination.
        Parameters:
        writer - PdfWriter
        rect - dimensions Rectangle
        highlight - title for the link
        namedDestination - destination for pdf annotation
        Returns:
        A PdfAnnotation
      • createLink

        public static PdfAnnotation createLink​(PdfWriter writer,
                                               Rectangle rect,
                                               PdfName highlight,
                                               int page,
                                               PdfDestination dest)
        Creates an Annotation with a PdfDestination.
        Parameters:
        writer - PdfWriter
        rect - dimensions Rectangle
        highlight - title for the link
        page - page
        dest - destination for pdf annotation
        Returns:
        A PdfAnnotation
      • createFreeText

        public static PdfAnnotation createFreeText​(PdfWriter writer,
                                                   Rectangle rect,
                                                   java.lang.String contents,
                                                   PdfContentByte defaultAppearance)
        Add some free text to the document.
        Parameters:
        writer - pdf writer
        rect - dimension
        contents - content of free text
        defaultAppearance - default appearance
        Returns:
        A PdfAnnotation
      • createLine

        public static PdfAnnotation createLine​(PdfWriter writer,
                                               Rectangle rect,
                                               java.lang.String contents,
                                               float x1,
                                               float y1,
                                               float x2,
                                               float y2)
        Adds a line to the document. Move over the line and a tooltip is shown.
        Parameters:
        writer - PdfWriter
        rect - dimensions Rectangle
        contents - content for the file
        x1 - x-coordinate
        y1 - y-coordinate
        x2 - x-coordinate
        y2 - y-coordinate
        Returns:
        A PdfAnnotation
      • createSquareCircle

        public static PdfAnnotation createSquareCircle​(PdfWriter writer,
                                                       Rectangle rect,
                                                       java.lang.String contents,
                                                       boolean square)
        Adds a circle or a square that shows a tooltip when you pass over it.
        Parameters:
        writer - pdf writer
        rect - dimension of the tooltip
        contents - The tooltip
        square - true if you want a square, false if you want a circle
        Returns:
        A PdfAnnotation
      • createMarkup

        public static PdfAnnotation createMarkup​(PdfWriter writer,
                                                 Rectangle rect,
                                                 java.lang.String contents,
                                                 int type,
                                                 float[] quadPoints)
      • createStamp

        public static PdfAnnotation createStamp​(PdfWriter writer,
                                                Rectangle rect,
                                                java.lang.String contents,
                                                java.lang.String name)
        Adds a Stamp to your document. Move over the stamp and a tooltip is shown
        Parameters:
        writer - PdfWriter
        rect - dimensions Rectangle
        contents - content for the file
        name - name of the annotation
        Returns:
        A PdfAnnotation
      • createFileAttachment

        public static PdfAnnotation createFileAttachment​(PdfWriter writer,
                                                         Rectangle rect,
                                                         java.lang.String contents,
                                                         byte[] fileStore,
                                                         java.lang.String file,
                                                         java.lang.String fileDisplay)
                                                  throws java.io.IOException
        Creates a file attachment annotation.
        Parameters:
        writer - the PdfWriter
        rect - the dimensions in the page of the annotation
        contents - the file description
        fileStore - an array with the file. If it's null the file will be read from the disk
        file - the path to the file. It will only be used if fileStore is not null
        fileDisplay - the actual file name stored in the pdf
        Returns:
        the annotation
        Throws:
        java.io.IOException - on error
      • createPopup

        public static PdfAnnotation createPopup​(PdfWriter writer,
                                                Rectangle rect,
                                                java.lang.String contents,
                                                boolean open)
        Adds a popup to your document.
        Parameters:
        writer - PdfWriter
        rect - dimensions Rectangle
        contents - content for the file
        open - if popup is open
        Returns:
        A PdfAnnotation
      • getMKColor

        public static PdfArray getMKColor​(java.awt.Color color)
      • getIndirectReference

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

        public void setDefaultAppearanceString​(PdfContentByte cb)
      • setFlags

        public void setFlags​(int flags)
      • addFlags

        public int addFlags​(int flags)
        Adds one or more flag(s) to the existing annotation flags
        Parameters:
        flags - value to be added
        Returns:
        int the new flag value
      • 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

        public void setAppearance​(PdfName ap,
                                  java.lang.String state,
                                  PdfTemplate template)
      • setAppearanceState

        public void setAppearanceState​(java.lang.String state)
      • setColor

        public void setColor​(java.awt.Color color)
      • setTitle

        public void setTitle​(java.lang.String title)
      • setAction

        public void setAction​(PdfAction action)
      • setAdditionalActions

        public void setAdditionalActions​(PdfName key,
                                         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 java.util.HashMap<PdfTemplate,​java.lang.Object> 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

        public 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)
      • setMKRotation

        public void setMKRotation​(int rotation)
      • setMKBorderColor

        public void setMKBorderColor​(java.awt.Color color)
      • setMKBackgroundColor

        public void setMKBackgroundColor​(java.awt.Color color)
      • setMKNormalCaption

        public void setMKNormalCaption​(java.lang.String caption)
      • setMKRolloverCaption

        public void setMKRolloverCaption​(java.lang.String caption)
      • setMKAlternateCaption

        public void setMKAlternateCaption​(java.lang.String caption)
      • setMKNormalIcon

        public void setMKNormalIcon​(PdfTemplate template)
      • setMKRolloverIcon

        public void setMKRolloverIcon​(PdfTemplate template)
      • setMKAlternateIcon

        public void setMKAlternateIcon​(PdfTemplate template)
      • setMKIconFit

        public 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​(java.lang.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 be set for annotation
      • addFKey

        private void addFKey()