Package com.lowagie.text.pdf
Class PdfAnnotation
java.lang.Object
com.lowagie.text.pdf.PdfObject
com.lowagie.text.pdf.PdfDictionary
com.lowagie.text.pdf.PdfAnnotation
- Direct Known Subclasses:
PdfFormField
A
PdfAnnotation
is a note that is associated with a page.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
This class processes links from imported pages so that they may be active. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PdfName
attributevaluestatic final PdfName
attributevaluestatic final PdfName
attributevaluestatic final PdfName
attributevaluestatic final PdfName
attributevaluestatic final PdfName
attributevaluestatic final PdfName
attributevaluestatic final PdfName
attributevaluestatic final PdfName
attributevaluestatic final PdfName
attributevalueprotected boolean
static final PdfName
appearance attributenamestatic final PdfName
appearance attributenamestatic final PdfName
appearance attributenamestatic final int
flagvaluestatic final int
flagvaluestatic final int
flagvaluestatic final int
flagvaluestatic final int
flagvaluestatic final int
flagvaluestatic final int
flagvaluestatic final int
flagvaluestatic final int
flagvalueprotected boolean
static final PdfName
highlight attributenamestatic final PdfName
highlight attributenamestatic final PdfName
highlight attributenamestatic final PdfName
highlight attributenamestatic final PdfName
highlight attributenamestatic final int
attributevaluestatic final int
attributevaluestatic final int
attributevaluestatic final int
attributevalueprivate int
Holds value of property placeInPage.protected PdfIndirectReference
Reference to this annotation.protected Map
<PdfTemplate, Object> protected boolean
Holds value of property used.protected PdfWriter
-
Constructor Summary
ConstructorsConstructorDescriptionPdfAnnotation
(PdfWriter writer, float llx, float lly, float urx, float ury, PdfAction action) Constructs a newPdfAnnotation
of subtype link (Action).PdfAnnotation
(PdfWriter writer, float llx, float lly, float urx, float ury, PdfString title, PdfString content) Constructs a newPdfAnnotation
of subtype text.PdfAnnotation
(PdfWriter writer, Rectangle rect) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addFKey()
int
addFlags
(int flags) Adds one or more flag(s) to the existing annotation flagsstatic PdfAnnotation
createFileAttachment
(PdfWriter writer, Rectangle rect, String contents, byte[] fileStore, String file, String fileDisplay) Creates a file attachment annotation.static PdfAnnotation
createFileAttachment
(PdfWriter writer, Rectangle rect, String contents, PdfFileSpecification fs) Creates a file attachment annotationstatic PdfAnnotation
createFreeText
(PdfWriter writer, Rectangle rect, String contents, PdfContentByte defaultAppearance) Add some free text to the document.static PdfAnnotation
static PdfAnnotation
createLine
(PdfWriter writer, Rectangle rect, String contents, float x1, float y1, float x2, float y2) Adds a line to the document.protected static PdfAnnotation
createLink
(PdfWriter writer, Rectangle rect, PdfName highlight) Creates a link.static PdfAnnotation
createLink
(PdfWriter writer, Rectangle rect, PdfName highlight, int page, PdfDestination dest) Creates an Annotation with a PdfDestination.static PdfAnnotation
createLink
(PdfWriter writer, Rectangle rect, PdfName highlight, PdfAction action) Creates an Annotation with an Action.static PdfAnnotation
createLink
(PdfWriter writer, Rectangle rect, PdfName highlight, String namedDestination) Creates an Annotation with an local destination.static PdfAnnotation
createMarkup
(PdfWriter writer, Rectangle rect, String contents, int type, float[] quadPoints) static PdfAnnotation
createPopup
(PdfWriter writer, Rectangle rect, String contents, boolean open) Adds a popup to your document.static PdfAnnotation
createScreen
(PdfWriter writer, Rectangle rect, String clipTitle, PdfFileSpecification fs, String mimeType, boolean playOnDisplay) Creates a screen PdfAnnotationstatic PdfAnnotation
createSquareCircle
(PdfWriter writer, Rectangle rect, String contents, boolean square) Adds a circle or a square that shows a tooltip when you pass over it.static PdfAnnotation
createStamp
(PdfWriter writer, Rectangle rect, String contents, String name) Adds a Stamp to your document.static PdfAnnotation
createText
(PdfWriter writer, Rectangle rect, String title, String contents, boolean open, String icon) Returns an indirect reference to the annotation(package private) PdfDictionary
getMK()
static PdfArray
getMKColor
(Color color) int
Getter for property placeInPage.boolean
Getter for property annotation.boolean
isForm()
Getter for property form.boolean
isUsed()
Getter for property used.void
void
setAdditionalActions
(PdfName key, PdfAction action) void
setAppearance
(PdfName ap, PdfTemplate template) void
setAppearance
(PdfName ap, String state, PdfTemplate template) void
setAppearanceState
(String state) void
setBorder
(PdfBorderArray border) void
setBorderStyle
(PdfBorderDictionary border) void
void
void
setFlags
(int flags) void
setHighlighting
(PdfName highlight) Sets the annotation's highlighting mode.void
Sets the layer this annotation belongs to.void
setMKAlternateCaption
(String caption) void
setMKAlternateIcon
(PdfTemplate template) void
setMKBackgroundColor
(Color color) void
setMKBorderColor
(Color color) void
setMKIconFit
(PdfName scale, PdfName scalingType, float leftoverLeft, float leftoverBottom, boolean fitInBounds) void
setMKNormalCaption
(String caption) void
setMKNormalIcon
(PdfTemplate template) void
setMKRolloverCaption
(String caption) void
setMKRolloverIcon
(PdfTemplate template) void
setMKRotation
(int rotation) void
setMKTextPosition
(int tp) void
Sets the name of the annotation.void
setPage()
void
setPage
(int page) void
setPlaceInPage
(int placeInPage) Places the annotation in a specified page that must be greater or equal to the current one.void
setPopup
(PdfAnnotation popup) void
setRotate
(int v) void
void
setUsed()
Setter for property used.Methods inherited from class com.lowagie.text.pdf.PdfDictionary
clear, contains, get, getAsArray, getAsBoolean, getAsDict, getAsIndirectObject, getAsName, getAsNumber, getAsStream, getAsString, getDirectObject, getKeys, getKeysAndValues, isCatalog, isFont, isOutlineTree, isPage, isPages, merge, mergeDifferent, put, putAll, putEx, remove, size, toPdf, toString
Methods inherited from class com.lowagie.text.pdf.PdfObject
canBeInObjStm, getBytes, getIndRef, isArray, isBoolean, isDictionary, isIndirect, isName, isNull, isNumber, isStream, isString, length, setContent, setIndRef, type
-
Field Details
-
HIGHLIGHT_NONE
highlight attributename -
HIGHLIGHT_INVERT
highlight attributename -
HIGHLIGHT_OUTLINE
highlight attributename -
HIGHLIGHT_PUSH
highlight attributename -
HIGHLIGHT_TOGGLE
highlight attributename -
FLAGS_INVISIBLE
public static final int FLAGS_INVISIBLEflagvalue- See Also:
-
FLAGS_HIDDEN
public static final int FLAGS_HIDDENflagvalue- See Also:
-
FLAGS_PRINT
public static final int FLAGS_PRINTflagvalue- See Also:
-
FLAGS_NOZOOM
public static final int FLAGS_NOZOOMflagvalue- See Also:
-
FLAGS_NOROTATE
public static final int FLAGS_NOROTATEflagvalue- See Also:
-
FLAGS_NOVIEW
public static final int FLAGS_NOVIEWflagvalue- See Also:
-
FLAGS_READONLY
public static final int FLAGS_READONLYflagvalue- See Also:
-
FLAGS_LOCKED
public static final int FLAGS_LOCKEDflagvalue- See Also:
-
FLAGS_TOGGLENOVIEW
public static final int FLAGS_TOGGLENOVIEWflagvalue- See Also:
-
APPEARANCE_NORMAL
appearance attributename -
APPEARANCE_ROLLOVER
appearance attributename -
APPEARANCE_DOWN
appearance attributename -
AA_ENTER
attributevalue -
AA_EXIT
attributevalue -
AA_DOWN
attributevalue -
AA_UP
attributevalue -
AA_FOCUS
attributevalue -
AA_BLUR
attributevalue -
AA_JS_KEY
attributevalue -
AA_JS_FORMAT
attributevalue -
AA_JS_CHANGE
attributevalue -
AA_JS_OTHER_CHANGE
attributevalue -
MARKUP_HIGHLIGHT
public static final int MARKUP_HIGHLIGHTattributevalue- See Also:
-
MARKUP_UNDERLINE
public static final int MARKUP_UNDERLINEattributevalue- See Also:
-
MARKUP_STRIKEOUT
public static final int MARKUP_STRIKEOUTattributevalue- See Also:
-
MARKUP_SQUIGGLY
public static final int MARKUP_SQUIGGLYattributevalue- Since:
- 2.1.3
- See Also:
-
writer
-
reference
Reference to this annotation.- Since:
- 2.1.6; was removed in 2.1.5, but restored in 2.1.6
-
templates
-
form
protected boolean form -
annotation
protected boolean annotation -
used
protected boolean usedHolds value of property used. -
placeInPage
private int placeInPageHolds value of property placeInPage.
-
-
Constructor Details
-
PdfAnnotation
-
PdfAnnotation
public PdfAnnotation(PdfWriter writer, float llx, float lly, float urx, float ury, PdfString title, PdfString content) Constructs a newPdfAnnotation
of subtype text.- Parameters:
writer
- pdf writerllx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-ytitle
- titlecontent
- content
-
PdfAnnotation
public PdfAnnotation(PdfWriter writer, float llx, float lly, float urx, float ury, PdfAction action) Constructs a newPdfAnnotation
of subtype link (Action).- Parameters:
writer
- pdf writerllx
- lower-left-xlly
- lower-left-yurx
- upper-right-xury
- upper-right-yaction
-PdfAction
-
-
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
-PdfWriter
rect
- dimensionsRectangle
clipTitle
- clip titlefs
-PdfFileSpecification
mimeType
- mime type of the fileplayOnDisplay
- play on display- Returns:
- a screen PdfAnnotation
- Throws:
IOException
- on error
-
createText
-
createLink
Creates a link. -
createLink
public static PdfAnnotation createLink(PdfWriter writer, Rectangle rect, PdfName highlight, PdfAction action) Creates an Annotation with an Action. -
createLink
public static PdfAnnotation createLink(PdfWriter writer, Rectangle rect, PdfName highlight, String namedDestination) Creates an Annotation with an local destination. -
createLink
public static PdfAnnotation createLink(PdfWriter writer, Rectangle rect, PdfName highlight, int page, PdfDestination dest) Creates an Annotation with a PdfDestination. -
createFreeText
public static PdfAnnotation createFreeText(PdfWriter writer, Rectangle rect, String contents, PdfContentByte defaultAppearance) Add some free text to the document.- Parameters:
writer
- pdf writerrect
- dimensioncontents
- content of free textdefaultAppearance
- default appearance- Returns:
- A PdfAnnotation
-
createLine
public static PdfAnnotation createLine(PdfWriter writer, Rectangle rect, 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. -
createSquareCircle
public static PdfAnnotation createSquareCircle(PdfWriter writer, Rectangle rect, String contents, boolean square) Adds a circle or a square that shows a tooltip when you pass over it.- Parameters:
writer
- pdf writerrect
- dimension of the tooltipcontents
- The tooltipsquare
- true if you want a square, false if you want a circle- Returns:
- A PdfAnnotation
-
createMarkup
public static PdfAnnotation createMarkup(PdfWriter writer, Rectangle rect, String contents, int type, float[] quadPoints) -
createStamp
public static PdfAnnotation createStamp(PdfWriter writer, Rectangle rect, String contents, String name) Adds a Stamp to your document. Move over the stamp and a tooltip is shown -
createInk
public static PdfAnnotation createInk(PdfWriter writer, Rectangle rect, String contents, float[][] inkList) -
createFileAttachment
public static PdfAnnotation createFileAttachment(PdfWriter writer, Rectangle rect, String contents, byte[] fileStore, String file, String fileDisplay) throws IOException Creates a file attachment annotation.- Parameters:
writer
- thePdfWriter
rect
- the dimensions in the page of the annotationcontents
- the file descriptionfileStore
- an array with the file. If it'snull
the file will be read from the diskfile
- the path to the file. It will only be used iffileStore
is notnull
fileDisplay
- the actual file name stored in the pdf- Returns:
- the annotation
- Throws:
IOException
- on error
-
createFileAttachment
public static PdfAnnotation createFileAttachment(PdfWriter writer, Rectangle rect, String contents, PdfFileSpecification fs) throws IOException Creates a file attachment annotation- Parameters:
writer
-PdfWriter
rect
- dimensionsRectangle
contents
- content for the filefs
-PdfFileSpecification
- Returns:
- the annotation
- Throws:
IOException
- on error
-
createPopup
public static PdfAnnotation createPopup(PdfWriter writer, Rectangle rect, String contents, boolean open) Adds a popup to your document. -
getMKColor
-
getIndirectReference
Returns an indirect reference to the annotation- Returns:
- the indirect reference
-
setDefaultAppearanceString
-
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
-
setBorder
-
setBorderStyle
-
setHighlighting
Sets the annotation's highlighting mode. The values can beHIGHLIGHT_NONE
,HIGHLIGHT_INVERT
,HIGHLIGHT_OUTLINE
andHIGHLIGHT_PUSH
;- Parameters:
highlight
- the annotation's highlighting mode
-
setAppearance
-
setAppearance
-
setAppearanceState
-
setColor
-
setTitle
-
setPopup
-
setAction
-
setAdditionalActions
-
isUsed
public boolean isUsed()Getter for property used.- Returns:
- Value of property used.
-
setUsed
public void setUsed()Setter for property used. -
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. WithPdfStamper
the page can be any. The first page is 1.- Parameters:
placeInPage
- New value of property placeInPage.
-
setRotate
public void setRotate(int v) -
getMK
PdfDictionary getMK() -
setMKRotation
public void setMKRotation(int rotation) -
setMKBorderColor
-
setMKBackgroundColor
-
setMKNormalCaption
-
setMKRolloverCaption
-
setMKAlternateCaption
-
setMKNormalIcon
-
setMKRolloverIcon
-
setMKAlternateIcon
-
setMKIconFit
-
setMKTextPosition
public void setMKTextPosition(int tp) -
setLayer
Sets the layer this annotation belongs to.- Parameters:
layer
- the layer this annotation belongs to
-
setName
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()
-