com.lowagie.text.pdf

Class PdfAnnotation

public class PdfAnnotation extends PdfDictionary

A PdfAnnotation is a note that is associated with a page.

See Also: PdfDictionary

Nested Class Summary
static classPdfAnnotation.PdfImportedLink
This class processes links from imported pages so that they may be active.
Field Summary
static PdfNameAA_BLUR
attributevalue
static PdfNameAA_DOWN
attributevalue
static PdfNameAA_ENTER
attributevalue
static PdfNameAA_EXIT
attributevalue
static PdfNameAA_FOCUS
attributevalue
static PdfNameAA_JS_CHANGE
attributevalue
static PdfNameAA_JS_FORMAT
attributevalue
static PdfNameAA_JS_KEY
attributevalue
static PdfNameAA_JS_OTHER_CHANGE
attributevalue
static PdfNameAA_UP
attributevalue
static PdfNameAPPEARANCE_DOWN
appearance attributename
static PdfNameAPPEARANCE_NORMAL
appearance attributename
static PdfNameAPPEARANCE_ROLLOVER
appearance attributename
protected booleanannotation
protected booleanform
static intFLAGS_HIDDEN
flagvalue
static intFLAGS_INVISIBLE
flagvalue
static intFLAGS_LOCKED
flagvalue
static intFLAGS_NOROTATE
flagvalue
static intFLAGS_NOVIEW
flagvalue
static intFLAGS_NOZOOM
flagvalue
static intFLAGS_PRINT
flagvalue
static intFLAGS_READONLY
flagvalue
static intFLAGS_TOGGLENOVIEW
flagvalue
static PdfNameHIGHLIGHT_INVERT
highlight attributename
static PdfNameHIGHLIGHT_NONE
highlight attributename
static PdfNameHIGHLIGHT_OUTLINE
highlight attributename
static PdfNameHIGHLIGHT_PUSH
highlight attributename
static PdfNameHIGHLIGHT_TOGGLE
highlight attributename
static intMARKUP_HIGHLIGHT
attributevalue
static intMARKUP_SQUIGGLY
attributevalue
static intMARKUP_STRIKEOUT
attributevalue
static intMARKUP_UNDERLINE
attributevalue
intplaceInPage
Holds value of property placeInPage.
protected HashMaptemplates
protected booleanused
Holds value of property used.
protected PdfWriterwriter
Constructor Summary
PdfAnnotation(PdfWriter writer, Rectangle rect)
PdfAnnotation(PdfWriter writer, float llx, float lly, float urx, float ury, PdfString title, PdfString content)
Constructs a new PdfAnnotation of subtype text.
PdfAnnotation(PdfWriter writer, float llx, float lly, float urx, float ury, PdfAction action)
Constructs a new PdfAnnotation of subtype link (Action).
Method Summary
static PdfAnnotationcreateFileAttachment(PdfWriter writer, Rectangle rect, String contents, byte[] fileStore, String file, String fileDisplay)
Creates a file attachment annotation.
static PdfAnnotationcreateFileAttachment(PdfWriter writer, Rectangle rect, String contents, PdfFileSpecification fs)
Creates a file attachment annotation
static PdfAnnotationcreateFreeText(PdfWriter writer, Rectangle rect, String contents, PdfContentByte defaultAppearance)
Add some free text to the document.
static PdfAnnotationcreateInk(PdfWriter writer, Rectangle rect, String contents, float[][] inkList)
static PdfAnnotationcreateLine(PdfWriter writer, Rectangle rect, String contents, float x1, float y1, float x2, float y2)
Adds a line to the document.
protected static PdfAnnotationcreateLink(PdfWriter writer, Rectangle rect, PdfName highlight)
Creates a link.
static PdfAnnotationcreateLink(PdfWriter writer, Rectangle rect, PdfName highlight, PdfAction action)
Creates an Annotation with an Action.
static PdfAnnotationcreateLink(PdfWriter writer, Rectangle rect, PdfName highlight, String namedDestination)
Creates an Annotation with an local destination.
static PdfAnnotationcreateLink(PdfWriter writer, Rectangle rect, PdfName highlight, int page, PdfDestination dest)
Creates an Annotation with a PdfDestination.
static PdfAnnotationcreateMarkup(PdfWriter writer, Rectangle rect, String contents, int type, float[] quadPoints)
static PdfAnnotationcreatePopup(PdfWriter writer, Rectangle rect, String contents, boolean open)
Adds a popup to your document.
static PdfAnnotationcreateScreen(PdfWriter writer, Rectangle rect, String clipTitle, PdfFileSpecification fs, String mimeType, boolean playOnDisplay)
Creates a screen PdfAnnotation
static PdfAnnotationcreateSquareCircle(PdfWriter writer, Rectangle rect, String contents, boolean square)
Adds a circle or a square that shows a tooltip when you pass over it.
static PdfAnnotationcreateStamp(PdfWriter writer, Rectangle rect, String contents, String name)
Adds a Stamp to your document.
static PdfAnnotationcreateText(PdfWriter writer, Rectangle rect, String title, String contents, boolean open, String icon)
PdfIndirectReferencegetIndirectReference()
PdfIndirectReferencegetIndRef()
Override base class behavior.
PdfDictionarygetMK()
static PdfArraygetMKColor(Color color)
intgetPlaceInPage()
Getter for property placeInPage.
HashMapgetTemplates()
booleanisAnnotation()
Getter for property annotation.
booleanisForm()
Getter for property form.
booleanisUsed()
Getter for property used.
voidsetAction(PdfAction action)
voidsetAdditionalActions(PdfName key, PdfAction action)
voidsetAppearance(PdfName ap, PdfTemplate template)
voidsetAppearance(PdfName ap, String state, PdfTemplate template)
voidsetAppearanceState(String state)
voidsetBorder(PdfBorderArray border)
voidsetBorderStyle(PdfBorderDictionary border)
voidsetColor(Color color)
voidsetDefaultAppearanceString(PdfContentByte cb)
voidsetFlags(int flags)
voidsetHighlighting(PdfName highlight)
Sets the annotation's highlighting mode.
voidsetLayer(PdfOCG layer)
Sets the layer this annotation belongs to.
voidsetMarkedObject(PdfStructureElement struc)
Set the structure element of this annotation.
voidsetMKAlternateCaption(String caption)
voidsetMKAlternateIcon(PdfTemplate template)
voidsetMKBackgroundColor(Color color)
voidsetMKBorderColor(Color color)
voidsetMKIconFit(PdfName scale, PdfName scalingType, float leftoverLeft, float leftoverBottom, boolean fitInBounds)
voidsetMKNormalCaption(String caption)
voidsetMKNormalIcon(PdfTemplate template)
voidsetMKRolloverCaption(String caption)
voidsetMKRolloverIcon(PdfTemplate template)
voidsetMKRotation(int rotation)
voidsetMKTextPosition(int tp)
voidsetName(String name)
Sets the name of the annotation.
voidsetPage(int page)
voidsetPage()
voidsetPlaceInPage(int placeInPage)
Places the annotation in a specified page that must be greater or equal to the current one.
voidsetPopup(PdfAnnotation popup)
voidsetRotate(int v)
voidsetTitle(String title)
voidsetUsed()
Setter for property used.

Field Detail

AA_BLUR

public static final PdfName AA_BLUR
attributevalue

AA_DOWN

public static final PdfName AA_DOWN
attributevalue

AA_ENTER

public static final PdfName AA_ENTER
attributevalue

AA_EXIT

public static final PdfName AA_EXIT
attributevalue

AA_FOCUS

public static final PdfName AA_FOCUS
attributevalue

AA_JS_CHANGE

public static final PdfName AA_JS_CHANGE
attributevalue

AA_JS_FORMAT

public static final PdfName AA_JS_FORMAT
attributevalue

AA_JS_KEY

public static final PdfName AA_JS_KEY
attributevalue

AA_JS_OTHER_CHANGE

public static final PdfName AA_JS_OTHER_CHANGE
attributevalue

AA_UP

public static final PdfName AA_UP
attributevalue

APPEARANCE_DOWN

public static final PdfName APPEARANCE_DOWN
appearance attributename

APPEARANCE_NORMAL

public static final PdfName APPEARANCE_NORMAL
appearance attributename

APPEARANCE_ROLLOVER

public static final PdfName APPEARANCE_ROLLOVER
appearance attributename

annotation

protected boolean annotation

form

protected boolean form

FLAGS_HIDDEN

public static final int FLAGS_HIDDEN
flagvalue

FLAGS_INVISIBLE

public static final int FLAGS_INVISIBLE
flagvalue

FLAGS_LOCKED

public static final int FLAGS_LOCKED
flagvalue

FLAGS_NOROTATE

public static final int FLAGS_NOROTATE
flagvalue

FLAGS_NOVIEW

public static final int FLAGS_NOVIEW
flagvalue

FLAGS_NOZOOM

public static final int FLAGS_NOZOOM
flagvalue

FLAGS_PRINT

public static final int FLAGS_PRINT
flagvalue

FLAGS_READONLY

public static final int FLAGS_READONLY
flagvalue

FLAGS_TOGGLENOVIEW

public static final int FLAGS_TOGGLENOVIEW
flagvalue

HIGHLIGHT_INVERT

public static final PdfName HIGHLIGHT_INVERT
highlight attributename

HIGHLIGHT_NONE

public static final PdfName HIGHLIGHT_NONE
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

MARKUP_HIGHLIGHT

public static final int MARKUP_HIGHLIGHT
attributevalue

MARKUP_SQUIGGLY

public static final int MARKUP_SQUIGGLY
attributevalue

Since: 2.1.3

MARKUP_STRIKEOUT

public static final int MARKUP_STRIKEOUT
attributevalue

MARKUP_UNDERLINE

public static final int MARKUP_UNDERLINE
attributevalue

placeInPage

private int placeInPage
Holds value of property placeInPage.

templates

protected HashMap templates

used

protected boolean used
Holds value of property used.

writer

protected PdfWriter writer

Constructor Detail

PdfAnnotation

public 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 llx lly urx ury title 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 llx lly urx ury action

Method Detail

createFileAttachment

public static PdfAnnotation createFileAttachment(PdfWriter writer, Rectangle rect, String contents, byte[] fileStore, String file, String fileDisplay)
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: IOException on error

createFileAttachment

public static PdfAnnotation createFileAttachment(PdfWriter writer, Rectangle rect, String contents, PdfFileSpecification fs)
Creates a file attachment annotation

Parameters: writer rect contents fs

Returns: the annotation

Throws: IOException

createFreeText

public static PdfAnnotation createFreeText(PdfWriter writer, Rectangle rect, String contents, PdfContentByte defaultAppearance)
Add some free text to the document.

Parameters: writer rect contents defaultAppearance

Returns: A PdfAnnotation

createInk

public static PdfAnnotation createInk(PdfWriter writer, Rectangle rect, String contents, float[][] inkList)

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.

Parameters: writer rect contents x1 y1 x2 y2

Returns: A PdfAnnotation

createLink

protected static PdfAnnotation createLink(PdfWriter writer, Rectangle rect, PdfName highlight)
Creates a link.

Parameters: writer rect highlight

Returns: A PdfAnnotation

createLink

public static PdfAnnotation createLink(PdfWriter writer, Rectangle rect, PdfName highlight, PdfAction action)
Creates an Annotation with an Action.

Parameters: writer rect highlight action

Returns: A PdfAnnotation

createLink

public static PdfAnnotation createLink(PdfWriter writer, Rectangle rect, PdfName highlight, String namedDestination)
Creates an Annotation with an local destination.

Parameters: writer rect highlight namedDestination

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 rect highlight page dest

Returns: A PdfAnnotation

createMarkup

public static PdfAnnotation createMarkup(PdfWriter writer, Rectangle rect, String contents, int type, float[] quadPoints)

createPopup

public static PdfAnnotation createPopup(PdfWriter writer, Rectangle rect, String contents, boolean open)
Adds a popup to your document.

Parameters: writer rect contents open

Returns: A PdfAnnotation

createScreen

public static PdfAnnotation createScreen(PdfWriter writer, Rectangle rect, String clipTitle, PdfFileSpecification fs, String mimeType, boolean playOnDisplay)
Creates a screen PdfAnnotation

Parameters: writer rect clipTitle fs mimeType playOnDisplay

Returns: a screen PdfAnnotation

Throws: IOException

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 rect contents The tooltip square true if you want a square, false if you want a circle

Returns: A PdfAnnotation

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

Parameters: writer rect contents name

Returns: A PdfAnnotation

createText

public static PdfAnnotation createText(PdfWriter writer, Rectangle rect, String title, String contents, boolean open, String icon)

Parameters: writer rect title contents open icon

Returns: a PdfAnnotation

getIndirectReference

public PdfIndirectReference getIndirectReference()

Deprecated: use getIndRef instead

Returns: the indirect reference

getIndRef

public PdfIndirectReference getIndRef()
Override base class behavior.

Returns: an indirect reference for this annotation

Since: 2.1.5

getMK

PdfDictionary getMK()

getMKColor

public static PdfArray getMKColor(Color color)

getPlaceInPage

public int getPlaceInPage()
Getter for property placeInPage.

Returns: Value of property placeInPage.

getTemplates

public HashMap getTemplates()

isAnnotation

public boolean isAnnotation()
Getter for property annotation.

Returns: Value of property annotation.

isForm

public boolean isForm()
Getter for property form.

Returns: Value of property form.

isUsed

public boolean isUsed()
Getter for property used.

Returns: Value of property used.

setAction

public void setAction(PdfAction action)

setAdditionalActions

public void setAdditionalActions(PdfName key, PdfAction action)

setAppearance

public void setAppearance(PdfName ap, PdfTemplate template)

setAppearance

public void setAppearance(PdfName ap, String state, PdfTemplate template)

setAppearanceState

public void setAppearanceState(String state)

setBorder

public void setBorder(PdfBorderArray border)

setBorderStyle

public void setBorderStyle(PdfBorderDictionary border)

setColor

public void setColor(Color color)

setDefaultAppearanceString

public void setDefaultAppearanceString(PdfContentByte cb)

setFlags

public void setFlags(int flags)

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

setLayer

public void setLayer(PdfOCG layer)
Sets the layer this annotation belongs to.

Parameters: layer the layer this annotation belongs to

setMarkedObject

public void setMarkedObject(PdfStructureElement struc)
Set the structure element of this annotation.

Parameters: struc

Since: 2.1.5

setMKAlternateCaption

public void setMKAlternateCaption(String caption)

setMKAlternateIcon

public void setMKAlternateIcon(PdfTemplate template)

setMKBackgroundColor

public void setMKBackgroundColor(Color color)

setMKBorderColor

public void setMKBorderColor(Color color)

setMKIconFit

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

setMKNormalCaption

public void setMKNormalCaption(String caption)

setMKNormalIcon

public void setMKNormalIcon(PdfTemplate template)

setMKRolloverCaption

public void setMKRolloverCaption(String caption)

setMKRolloverIcon

public void setMKRolloverIcon(PdfTemplate template)

setMKRotation

public void setMKRotation(int rotation)

setMKTextPosition

public void setMKTextPosition(int tp)

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).

setPage

public void setPage(int page)

setPage

public void setPage()

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.

setPopup

public void setPopup(PdfAnnotation popup)

setRotate

public void setRotate(int v)

setTitle

public void setTitle(String title)

setUsed

public void setUsed()
Setter for property used.