Package com.itextpdf.kernel.pdf.annot
Class PdfAnnotation
- java.lang.Object
-
- com.itextpdf.kernel.pdf.PdfObjectWrapper<PdfDictionary>
-
- com.itextpdf.kernel.pdf.annot.PdfAnnotation
-
- Direct Known Subclasses:
Pdf3DAnnotation
,PdfAnnotation.PdfUnknownAnnotation
,PdfLinkAnnotation
,PdfMarkupAnnotation
,PdfPopupAnnotation
,PdfPrinterMarkAnnotation
,PdfScreenAnnotation
,PdfTrapNetworkAnnotation
,PdfWatermarkAnnotation
,PdfWidgetAnnotation
public abstract class PdfAnnotation extends PdfObjectWrapper<PdfDictionary>
This is a super class for the annotation dictionary wrappers. Derived classes represent different standard types of annotations. See ISO-320001 12.5.6, "Annotation Types."
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
PdfAnnotation.PdfUnknownAnnotation
-
Field Summary
Fields Modifier and Type Field Description static PdfString
Accepted
Annotation state.static PdfString
Canceled
Annotation state.static PdfString
Completed
Annotation state.static int
HIDDEN
Annotation flag.static PdfName
HIGHLIGHT_INVERT
Widget annotation highlighting mode.static PdfName
HIGHLIGHT_NONE
Widget annotation highlighting mode.static PdfName
HIGHLIGHT_OUTLINE
Widget annotation highlighting mode.static PdfName
HIGHLIGHT_PUSH
Widget annotation highlighting mode.static PdfName
HIGHLIGHT_TOGGLE
Widget annotation highlighting mode.static int
INVISIBLE
Annotation flag.static int
LOCKED
Annotation flag.static int
LOCKED_CONTENTS
Annotation flag.static PdfString
Marked
Annotation state.static PdfString
MarkedModel
Annotation state model.static int
NO_ROTATE
Annotation flag.static int
NO_VIEW
Annotation flag.static int
NO_ZOOM
Annotation flag.static PdfString
None
Annotation state.protected PdfPage
page
static int
PRINT
Annotation flag.static int
READ_ONLY
Annotation flag.static PdfString
Rejected
Annotation state.static PdfString
ReviewModel
Annotation state model.static PdfName
STYLE_BEVELED
Annotation border style.static PdfName
STYLE_DASHED
Annotation border style.static PdfName
STYLE_INSET
Annotation border style.static PdfName
STYLE_SOLID
Annotation border style.static PdfName
STYLE_UNDERLINE
Annotation border style.static int
TOGGLE_NO_VIEW
Annotation flag.static PdfString
Unmarked
Annotation state.
-
Constructor Summary
Constructors Modifier Constructor Description protected
PdfAnnotation(Rectangle rect)
protected
PdfAnnotation(PdfDictionary pdfObject)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addAssociatedFile(PdfFileSpec fs)
Adds file associated with PDF annotation and identifies the relationship between them.void
flush()
To manually flush aPdfObject
behind this wrapper, you have to ensure that this object is added to the document, i.e.PdfDictionary
getAppearanceDictionary()
An appearance dictionary specifying how the annotation shall be presented visually on the page during its interactions with the user (see ISO-320001 12.5.5, "Appearance Streams").PdfDictionary
getAppearanceObject(PdfName appearanceType)
Specific appearance object corresponding to the specific appearance type.PdfName
getAppearanceState()
The annotation’s appearance state, which selects the applicable appearance stream from an appearance subdictionary if there is such.PdfArray
getAssociatedFiles(boolean create)
Returns files associated with PDF annotation.PdfName
getBlendMode()
PDF 2.0.PdfArray
getBorder()
An array specifying the characteristics of the annotation’s border.PdfArray
getColorObject()
An array of numbers in the range 0.0 to 1.0, representing a colour used for the following purposes: The background of the annotation’s icon when closed The title bar of the annotation’s pop-up window The border of a link annotation The number of array elements determines the colour space in which the colour shall be defined: 0 - No colour; transparent 1 - DeviceGray 3 - DeviceRGB 4 - DeviceCMYKPdfString
getContents()
Gets the text that shall be displayed for the annotation or, if this type of annotation does not display text, an alternate description of the annotation’s contents in human-readable form.PdfString
getDate()
The date and time when the annotation was most recently modified.PdfDictionary
getDownAppearanceObject()
The down appearance is used when the mouse button is pressed or held down within the annotation’s active area.int
getFlags()
A set of flags specifying various characteristics of the annotation (see ISO-320001 12.5.3, "Annotation Flags").java.lang.String
getLang()
PDF 2.0.PdfString
getName()
Gets the annotation name, a text string uniquely identifying it among all the annotations on its page.float
getNonStrokingOpacity()
PDF 2.0.PdfDictionary
getNormalAppearanceObject()
The normal appearance is used when the annotation is not interacting with the user.PdfPage
getPage()
Gets aPdfPage
on which annotation is placed.PdfDictionary
getPageObject()
Gets aPdfDictionary
that represents a page of the document on which annotation is placed, i.e.PdfArray
getRectangle()
The annotation rectangle, defining the location of the annotation on the page in default user space units.PdfDictionary
getRolloverAppearanceObject()
The rollover appearance is used when the user moves the cursor into the annotation’s active area without pressing the mouse button.float
getStrokingOpacity()
PDF 2.0.int
getStructParentIndex()
The integer key of the annotation’s entry in the structural parent tree (see ISO-320001 14.7.4.4, "Finding Structure Elements from Content Items").abstract PdfName
getSubtype()
Gets aPdfName
which value is a subtype of this annotation.PdfString
getTitle()
Annotation title.boolean
hasFlag(int flag)
Checks if the certain flag that specifies a characteristic of the annotation is in enabled state (see ISO-320001 12.5.3, "Annotation Flags").protected boolean
isWrappedObjectMustBeIndirect()
Defines if the object behind this wrapper must be an indirect object in the resultant document.static PdfAnnotation
makeAnnotation(PdfObject pdfObject)
Factory method that creates the type specificPdfAnnotation
from the givenPdfObject
that represents annotation object.PdfAnnotation
put(PdfName key, PdfObject value)
Inserts the value into into the underlyingPdfDictionary
of thisPdfAnnotation
and associates it with the specified key.PdfAnnotation
remove(PdfName key)
Removes the specified key from the underlyingPdfDictionary
of thisPdfAnnotation
.PdfAnnotation
resetFlag(int flag)
Resets a flag that specifies a characteristic of the annotation to disabled state (see ISO-320001 12.5.3, "Annotation Flags").PdfAnnotation
setAppearance(PdfName appearanceType, PdfAnnotationAppearance appearance)
Sets a specific type of the appearance usingPdfAnnotationAppearance
wrapper.PdfAnnotation
setAppearance(PdfName appearanceType, PdfDictionary appearance)
Sets a specific type of the appearance.PdfAnnotation
setAppearanceState(PdfName as)
Sets the annotation’s appearance state, which selects the applicable appearance stream from an appearance subdictionary.PdfAnnotation
setBlendMode(PdfName blendMode)
PDF 2.0.PdfAnnotation
setBorder(PdfAnnotationBorder border)
Sets the characteristics of the annotation’s border.PdfAnnotation
setBorder(PdfArray border)
Sets the characteristics of the annotation’s border.PdfAnnotation
setColor(float[] color)
Sets an annotation color.PdfAnnotation
setColor(Color color)
Sets an annotation color.PdfAnnotation
setColor(PdfArray color)
Sets an annotation color.PdfAnnotation
setContents(PdfString contents)
Sets the text that shall be displayed for the annotation or, if this type of annotation does not display text, an alternate description of the annotation’s contents in human-readable form.PdfAnnotation
setContents(java.lang.String contents)
Sets the text that shall be displayed for the annotation or, if this type of annotation does not display text, an alternate description of the annotation’s contents in human-readable form.PdfAnnotation
setDate(PdfString date)
The date and time when the annotation was most recently modified.PdfAnnotation
setDownAppearance(PdfAnnotationAppearance appearance)
Sets down appearance usingPdfAnnotationAppearance
wrapper.PdfAnnotation
setDownAppearance(PdfDictionary appearance)
Sets down appearance.PdfAnnotation
setFlag(int flag)
Sets a flag that specifies a characteristic of the annotation to enabled state (see ISO-320001 12.5.3, "Annotation Flags").PdfAnnotation
setFlags(int flags)
Sets a set of flags specifying various characteristics of the annotation (see ISO-320001 12.5.3, "Annotation Flags").PdfAnnotation
setLang(java.lang.String lang)
PDF 2.0.void
setLayer(IPdfOCG layer)
Sets the layer this annotation belongs to.PdfAnnotation
setName(PdfString name)
Sets the annotation name, a text string uniquely identifying it among all the annotations on its page.PdfAnnotation
setNonStrokingOpacity(float nonStrokingOpacity)
PDF 2.0.PdfAnnotation
setNormalAppearance(PdfAnnotationAppearance appearance)
Sets normal appearance usingPdfAnnotationAppearance
wrapper.PdfAnnotation
setNormalAppearance(PdfDictionary appearance)
Sets normal appearance.PdfAnnotation
setPage(PdfPage page)
Method that modifies annotation page property, which defines to which page annotation belongs.PdfAnnotation
setRectangle(PdfArray array)
The annotation rectangle, defining the location of the annotation on the page in default user space units.PdfAnnotation
setRolloverAppearance(PdfAnnotationAppearance appearance)
Sets rollover appearance usingPdfAnnotationAppearance
wrapper.PdfAnnotation
setRolloverAppearance(PdfDictionary appearance)
Sets rollover appearance.PdfAnnotation
setStrokingOpacity(float strokingOpacity)
PDF 2.0.PdfAnnotation
setStructParentIndex(int structParentIndex)
Sets he integer key of the annotation’s entry in the structural parent tree (see ISO-320001 14.7.4.4, "Finding Structure Elements from Content Items").PdfAnnotation
setTitle(PdfString title)
Sets annotation title.-
Methods inherited from class com.itextpdf.kernel.pdf.PdfObjectWrapper
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
-
-
-
-
Field Detail
-
INVISIBLE
public static final int INVISIBLE
Annotation flag. See alsosetFlag(int)
and ISO-320001, table 165.- See Also:
- Constant Field Values
-
HIDDEN
public static final int HIDDEN
Annotation flag. See alsosetFlag(int)
and ISO-320001, table 165.- See Also:
- Constant Field Values
-
PRINT
public static final int PRINT
Annotation flag. See alsosetFlag(int)
and ISO-320001, table 165.- See Also:
- Constant Field Values
-
NO_ZOOM
public static final int NO_ZOOM
Annotation flag. See alsosetFlag(int)
and ISO-320001, table 165.- See Also:
- Constant Field Values
-
NO_ROTATE
public static final int NO_ROTATE
Annotation flag. See alsosetFlag(int)
and ISO-320001, table 165.- See Also:
- Constant Field Values
-
NO_VIEW
public static final int NO_VIEW
Annotation flag. See alsosetFlag(int)
and ISO-320001, table 165.- See Also:
- Constant Field Values
-
READ_ONLY
public static final int READ_ONLY
Annotation flag. See alsosetFlag(int)
and ISO-320001, table 165.- See Also:
- Constant Field Values
-
LOCKED
public static final int LOCKED
Annotation flag. See alsosetFlag(int)
and ISO-320001, table 165.- See Also:
- Constant Field Values
-
TOGGLE_NO_VIEW
public static final int TOGGLE_NO_VIEW
Annotation flag. See alsosetFlag(int)
and ISO-320001, table 165.- See Also:
- Constant Field Values
-
LOCKED_CONTENTS
public static final int LOCKED_CONTENTS
Annotation flag. See alsosetFlag(int)
and ISO-320001, table 165.- See Also:
- Constant Field Values
-
HIGHLIGHT_NONE
public static final PdfName HIGHLIGHT_NONE
Widget annotation highlighting mode. See ISO-320001, Table 188 (H key). Also seePdfWidgetAnnotation.setHighlightMode(PdfName)
.
-
HIGHLIGHT_INVERT
public static final PdfName HIGHLIGHT_INVERT
Widget annotation highlighting mode. See ISO-320001, Table 188 (H key). Also seePdfWidgetAnnotation.setHighlightMode(PdfName)
.
-
HIGHLIGHT_OUTLINE
public static final PdfName HIGHLIGHT_OUTLINE
Widget annotation highlighting mode. See ISO-320001, Table 188 (H key). Also seePdfWidgetAnnotation.setHighlightMode(PdfName)
.
-
HIGHLIGHT_PUSH
public static final PdfName HIGHLIGHT_PUSH
Widget annotation highlighting mode. See ISO-320001, Table 188 (H key). Also seePdfWidgetAnnotation.setHighlightMode(PdfName)
.
-
HIGHLIGHT_TOGGLE
public static final PdfName HIGHLIGHT_TOGGLE
Widget annotation highlighting mode. See ISO-320001, Table 188 (H key). Also seePdfWidgetAnnotation.setHighlightMode(PdfName)
.
-
STYLE_SOLID
public static final PdfName STYLE_SOLID
Annotation border style. See ISO-320001, Table 166 (S key).
-
STYLE_DASHED
public static final PdfName STYLE_DASHED
Annotation border style. See ISO-320001, Table 166 (S key).
-
STYLE_BEVELED
public static final PdfName STYLE_BEVELED
Annotation border style. See ISO-320001, Table 166 (S key).
-
STYLE_INSET
public static final PdfName STYLE_INSET
Annotation border style. See ISO-320001, Table 166 (S key).
-
STYLE_UNDERLINE
public static final PdfName STYLE_UNDERLINE
Annotation border style. See ISO-320001, Table 166 (S key).
-
Marked
public static final PdfString Marked
Annotation state. See ISO-320001 12.5.6.3 "Annotation States" and Table 171 in particular. Also seePdfTextAnnotation.setState(PdfString)
.
-
Unmarked
public static final PdfString Unmarked
Annotation state. See ISO-320001 12.5.6.3 "Annotation States" and Table 171 in particular. Also seePdfTextAnnotation.setState(PdfString)
.
-
Accepted
public static final PdfString Accepted
Annotation state. See ISO-320001 12.5.6.3 "Annotation States" and Table 171 in particular. Also seePdfTextAnnotation.setState(PdfString)
.
-
Rejected
public static final PdfString Rejected
Annotation state. See ISO-320001 12.5.6.3 "Annotation States" and Table 171 in particular. Also seePdfTextAnnotation.setState(PdfString)
.
-
Canceled
public static final PdfString Canceled
Annotation state. See ISO-320001 12.5.6.3 "Annotation States" and Table 171 in particular. Also seePdfTextAnnotation.setState(PdfString)
.
-
Completed
public static final PdfString Completed
Annotation state. See ISO-320001 12.5.6.3 "Annotation States" and Table 171 in particular. Also seePdfTextAnnotation.setState(PdfString)
.
-
None
public static final PdfString None
Annotation state. See ISO-320001 12.5.6.3 "Annotation States" and Table 171 in particular. Also seePdfTextAnnotation.setState(PdfString)
.
-
MarkedModel
public static final PdfString MarkedModel
Annotation state model. See ISO-320001, Table 172 (StateModel key). Also seePdfTextAnnotation.setStateModel(PdfString)
.
-
ReviewModel
public static final PdfString ReviewModel
Annotation state model. See ISO-320001, Table 172 (StateModel key). Also seePdfTextAnnotation.setStateModel(PdfString)
.
-
page
protected PdfPage page
-
-
Constructor Detail
-
PdfAnnotation
protected PdfAnnotation(Rectangle rect)
-
PdfAnnotation
protected PdfAnnotation(PdfDictionary pdfObject)
-
-
Method Detail
-
makeAnnotation
public static PdfAnnotation makeAnnotation(PdfObject pdfObject)
Factory method that creates the type specificPdfAnnotation
from the givenPdfObject
that represents annotation object. This method is useful for property reading in reading mode or modifying in stamping mode. See derived classes of this class to see possible specific annotation types created.- Parameters:
pdfObject
- aPdfObject
that represents annotation in the document.- Returns:
- created
PdfAnnotation
.
-
getSubtype
public abstract PdfName getSubtype()
Gets aPdfName
which value is a subtype of this annotation. See ISO-320001 12.5.6, "Annotation Types" for the reference to the possible types.- Returns:
- subtype of this annotation.
-
setLayer
public void setLayer(IPdfOCG layer)
Sets the layer this annotation belongs to.- Parameters:
layer
- the layer this annotation belongs to
-
getContents
public PdfString getContents()
Gets the text that shall be displayed for the annotation or, if this type of annotation does not display text, an alternate description of the annotation’s contents in human-readable form.- Returns:
- annotation text content.
-
setContents
public PdfAnnotation setContents(PdfString contents)
Sets the text that shall be displayed for the annotation or, if this type of annotation does not display text, an alternate description of the annotation’s contents in human-readable form.- Parameters:
contents
- aPdfString
containing text content to be set to the annotation.- Returns:
- this
PdfAnnotation
instance.
-
setContents
public PdfAnnotation setContents(java.lang.String contents)
Sets the text that shall be displayed for the annotation or, if this type of annotation does not display text, an alternate description of the annotation’s contents in human-readable form.- Parameters:
contents
- a javaString
containing text content to be set to the annotation.- Returns:
- this
PdfAnnotation
instance.
-
getPageObject
public PdfDictionary getPageObject()
Gets aPdfDictionary
that represents a page of the document on which annotation is placed, i.e. which has this annotation in it's /Annots array.- Returns:
PdfDictionary
that is a page pdf object or null if annotation is not added to the page yet.
-
getPage
public PdfPage getPage()
Gets aPdfPage
on which annotation is placed.- Returns:
PdfPage
on which annotation is placed or null if annotation is not placed yet.
-
setPage
public PdfAnnotation setPage(PdfPage page)
Method that modifies annotation page property, which defines to which page annotation belongs. Keep in mind that this doesn't actually add an annotation to the page, it should be done viaPdfPage.addAnnotation(PdfAnnotation)
. Also you don't need to set this property manually, this is done automatically on addition to the page.- Parameters:
page
- thePdfPage
to which annotation will be added.- Returns:
- this
PdfAnnotation
instance.
-
getName
public PdfString getName()
Gets the annotation name, a text string uniquely identifying it among all the annotations on its page.- Returns:
- a
PdfString
with annotation name as it's value or null if name is not specified.
-
setName
public PdfAnnotation setName(PdfString name)
Sets the annotation name, a text string uniquely identifying it among all the annotations on its page.- Parameters:
name
- aPdfString
to be set as annotation name.- Returns:
- this
PdfAnnotation
instance.
-
getDate
public PdfString getDate()
The date and time when the annotation was most recently modified. This is an optional property of the annotation.- Returns:
- a
PdfString
with the modification date as it's value or null if date is not specified.
-
setDate
public PdfAnnotation setDate(PdfString date)
The date and time when the annotation was most recently modified.- Parameters:
date
- aPdfString
with date. The format should be a date string as described in ISO-320001 7.9.4, "Dates".- Returns:
- this
PdfAnnotation
instance.
-
getFlags
public int getFlags()
A set of flags specifying various characteristics of the annotation (see ISO-320001 12.5.3, "Annotation Flags"). For specific annotation flag constants seesetFlag(int)
. Default value: 0.- Returns:
- an integer interpreted as one-bit flags specifying various characteristics of the annotation.
-
setFlags
public PdfAnnotation setFlags(int flags)
Sets a set of flags specifying various characteristics of the annotation (see ISO-320001 12.5.3, "Annotation Flags"). On the contrary fromsetFlag(int)
, this method sets a complete set of enabled and disabled flags at once. If not set specifically the default value is 0.- Parameters:
flags
- an integer interpreted as set of one-bit flags specifying various characteristics of the annotation.- Returns:
- this
PdfAnnotation
instance.
-
setFlag
public PdfAnnotation setFlag(int flag)
Sets a flag that specifies a characteristic of the annotation to enabled state (see ISO-320001 12.5.3, "Annotation Flags"). On the contrary fromsetFlags(int)
, this method sets only specified flags to enabled state, but doesn't disable other flags. Possible flags:INVISIBLE
- If set, do not display the annotation if it does not belong to one of the standard annotation types and no annotation handler is available. If clear, display such unknown annotation using an appearance stream specified by its appearance dictionary, if any.HIDDEN
- If set, do not display or print the annotation or allow it to interact with the user, regardless of its annotation type or whether an annotation handler is available.PRINT
- If set, print the annotation when the page is printed. If clear, never print the annotation, regardless of whether it is displayed on the screen.NO_ZOOM
- If set, do not scale the annotation’s appearance to match the magnification of the page. The location of the annotation on the page (defined by the upper-left corner of its annotation rectangle) shall remain fixed, regardless of the page magnification.}NO_ROTATE
- If set, do not rotate the annotation’s appearance to match the rotation of the page. The upper-left corner of the annotation rectangle shall remain in a fixed location on the page, regardless of the page rotation.NO_VIEW
- If set, do not display the annotation on the screen or allow it to interact with the user. The annotation may be printed (depending on the setting of the Print flag) but should be considered hidden for purposes of on-screen display and user interaction.READ_ONLY
- If set, do not allow the annotation to interact with the user. The annotation may be displayed or printed (depending on the settings of the NoView and Print flags) but should not respond to mouse clicks or change its appearance in response to mouse motions.LOCKED
- If set, do not allow the annotation to be deleted or its properties (including position and size) to be modified by the user. However, this flag does not restrict changes to the annotation’s contents, such as the value of a form field.TOGGLE_NO_VIEW
- If set, invert the interpretation of the NoView flag for certain events.LOCKED_CONTENTS
- If set, do not allow the contents of the annotation to be modified by the user. This flag does not restrict deletion of the annotation or changes to other annotation properties, such as position and size.
- Parameters:
flag
- - an integer interpreted as set of one-bit flags which will be enabled for this annotation.- Returns:
- this
PdfAnnotation
instance.
-
resetFlag
public PdfAnnotation resetFlag(int flag)
Resets a flag that specifies a characteristic of the annotation to disabled state (see ISO-320001 12.5.3, "Annotation Flags").- Parameters:
flag
- an integer interpreted as set of one-bit flags which will be reset to disabled state.- Returns:
- this
PdfAnnotation
instance.
-
hasFlag
public boolean hasFlag(int flag)
Checks if the certain flag that specifies a characteristic of the annotation is in enabled state (see ISO-320001 12.5.3, "Annotation Flags"). This method allows only one flag to be checked at once, use constants listed insetFlag(int)
.- Parameters:
flag
- an integer interpreted as set of one-bit flags. Only one bit must be set in this integer, otherwise exception is thrown.- Returns:
- true if the given flag is in enabled state.
-
getAppearanceDictionary
public PdfDictionary getAppearanceDictionary()
An appearance dictionary specifying how the annotation shall be presented visually on the page during its interactions with the user (see ISO-320001 12.5.5, "Appearance Streams"). An appearance dictionary is a dictionary containing one or several appearance streams or subdictionaries.- Returns:
- an appearance
PdfDictionary
or null if it is not specified.
-
getAppearanceObject
public PdfDictionary getAppearanceObject(PdfName appearanceType)
Specific appearance object corresponding to the specific appearance type. This object might be either an appearance stream or an appearance subdictionary. In the latter case, the subdictionary defines multiple appearance streams corresponding to different appearance states of the annotation. See ISO-320001 12.5.5, "Appearance Streams".
-
getNormalAppearanceObject
public PdfDictionary getNormalAppearanceObject()
The normal appearance is used when the annotation is not interacting with the user. This appearance is also used for printing the annotation. See alsogetAppearanceObject(PdfName)
.- Returns:
- an appearance object which might be either an appearance stream or an appearance subdictionary.
-
getRolloverAppearanceObject
public PdfDictionary getRolloverAppearanceObject()
The rollover appearance is used when the user moves the cursor into the annotation’s active area without pressing the mouse button. If not specified normal appearance is used. See alsogetAppearanceObject(PdfName)
.- Returns:
- null if rollover appearance is not specified or an appearance object which might be either an appearance stream or an appearance subdictionary.
-
getDownAppearanceObject
public PdfDictionary getDownAppearanceObject()
The down appearance is used when the mouse button is pressed or held down within the annotation’s active area. If not specified normal appearance is used. See alsogetAppearanceObject(PdfName)
.- Returns:
- null if down appearance is not specified or an appearance object which might be either an appearance stream or an appearance subdictionary.
-
setAppearance
public PdfAnnotation setAppearance(PdfName appearanceType, PdfDictionary appearance)
Sets a specific type of the appearance. SeegetAppearanceObject(PdfName)
andgetAppearanceDictionary()
for more info.- Parameters:
appearanceType
- aPdfName
specifying appearance type. Possible types areNormal
,Rollover
andDown
.appearance
- an appearance object which might be either an appearance stream or an appearance subdictionary.- Returns:
- this
PdfAnnotation
instance.
-
setNormalAppearance
public PdfAnnotation setNormalAppearance(PdfDictionary appearance)
Sets normal appearance. SeegetNormalAppearanceObject()
andgetAppearanceDictionary()
for more info.- Parameters:
appearance
- an appearance object which might be either an appearance stream or an appearance subdictionary.- Returns:
- this
PdfAnnotation
instance.
-
setRolloverAppearance
public PdfAnnotation setRolloverAppearance(PdfDictionary appearance)
Sets rollover appearance. SeegetRolloverAppearanceObject()
andgetAppearanceDictionary()
for more info.- Parameters:
appearance
- an appearance object which might be either an appearance stream or an appearance subdictionary.- Returns:
- this
PdfAnnotation
instance.
-
setDownAppearance
public PdfAnnotation setDownAppearance(PdfDictionary appearance)
Sets down appearance. SeegetDownAppearanceObject()
andgetAppearanceDictionary()
for more info.- Parameters:
appearance
- an appearance object which might be either an appearance stream or an appearance subdictionary.- Returns:
- this
PdfAnnotation
instance.
-
setAppearance
public PdfAnnotation setAppearance(PdfName appearanceType, PdfAnnotationAppearance appearance)
Sets a specific type of the appearance usingPdfAnnotationAppearance
wrapper. This method is used to set only an appearance subdictionary. SeegetAppearanceObject(PdfName)
andgetAppearanceDictionary()
for more info.- Parameters:
appearanceType
- aPdfName
specifying appearance type. Possible types areNormal
,Rollover
andDown
.appearance
- an appearance subdictionary wrapped inPdfAnnotationAppearance
.- Returns:
- this
PdfAnnotation
instance.
-
setNormalAppearance
public PdfAnnotation setNormalAppearance(PdfAnnotationAppearance appearance)
Sets normal appearance usingPdfAnnotationAppearance
wrapper. This method is used to set only appearance subdictionary. SeegetNormalAppearanceObject()
andgetAppearanceDictionary()
for more info.- Parameters:
appearance
- an appearance subdictionary wrapped inPdfAnnotationAppearance
.- Returns:
- this
PdfAnnotation
instance.
-
setRolloverAppearance
public PdfAnnotation setRolloverAppearance(PdfAnnotationAppearance appearance)
Sets rollover appearance usingPdfAnnotationAppearance
wrapper. This method is used to set only appearance subdictionary. SeegetRolloverAppearanceObject()
andgetAppearanceDictionary()
for more info.- Parameters:
appearance
- an appearance subdictionary wrapped inPdfAnnotationAppearance
.- Returns:
- this
PdfAnnotation
instance.
-
setDownAppearance
public PdfAnnotation setDownAppearance(PdfAnnotationAppearance appearance)
Sets down appearance usingPdfAnnotationAppearance
wrapper. This method is used to set only appearance subdictionary. SeegetDownAppearanceObject()
andgetAppearanceDictionary()
for more info.- Parameters:
appearance
- an appearance subdictionary wrapped inPdfAnnotationAppearance
.- Returns:
- this
PdfAnnotation
instance.
-
getAppearanceState
public PdfName getAppearanceState()
The annotation’s appearance state, which selects the applicable appearance stream from an appearance subdictionary if there is such. SeegetAppearanceObject(PdfName)
for more info.- Returns:
- a
PdfName
which defines selected appearance state.
-
setAppearanceState
public PdfAnnotation setAppearanceState(PdfName as)
Sets the annotation’s appearance state, which selects the applicable appearance stream from an appearance subdictionary. SeegetAppearanceObject(PdfName)
for more info.- Parameters:
as
- aPdfName
which defines appearance state to be selected.- Returns:
- this
PdfAnnotation
instance.
-
getBorder
public PdfArray getBorder()
An array specifying the characteristics of the annotation’s border. The array consists of three numbers defining the horizontal corner radius, vertical corner radius, and border width, all in default user space units. If the corner radii are 0, the border has square (not rounded) corners; if the border width is 0, no border is drawn.The array may have a fourth element, an optional dash array (see ISO-320001 8.4.3.6, "Line Dash Pattern").
- Returns:
- an
PdfArray
specifying the characteristics of the annotation’s border.
-
setBorder
public PdfAnnotation setBorder(PdfAnnotationBorder border)
Sets the characteristics of the annotation’s border.- Parameters:
border
- anPdfAnnotationBorder
specifying the characteristics of the annotation’s border. SeegetBorder()
for more detailes.- Returns:
- this
PdfAnnotation
instance.
-
setBorder
public PdfAnnotation setBorder(PdfArray border)
Sets the characteristics of the annotation’s border.- Parameters:
border
- anPdfArray
specifying the characteristics of the annotation’s border. SeegetBorder()
for more detailes.- Returns:
- this
PdfAnnotation
instance.
-
getColorObject
public PdfArray getColorObject()
An array of numbers in the range 0.0 to 1.0, representing a colour used for the following purposes:- The background of the annotation’s icon when closed
- The title bar of the annotation’s pop-up window
- The border of a link annotation
- 0 - No colour; transparent
- 1 - DeviceGray
- 3 - DeviceRGB
- 4 - DeviceCMYK
- Returns:
- An array of numbers in the range 0.0 to 1.0, representing an annotation colour.
-
setColor
public PdfAnnotation setColor(PdfArray color)
Sets an annotation color. For more details on annotation color purposes and the format of the passingPdfArray
seegetColorObject()
.- Parameters:
color
- an array of numbers in the range 0.0 to 1.0, specifying color.- Returns:
- this
PdfAnnotation
instance.
-
setColor
public PdfAnnotation setColor(float[] color)
Sets an annotation color. For more details on annotation color purposes and the format of the passing array seegetColorObject()
.- Parameters:
color
- an array of numbers in the range 0.0 to 1.0, specifying color.- Returns:
- this
PdfAnnotation
instance.
-
setColor
public PdfAnnotation setColor(Color color)
Sets an annotation color. For more details on annotation color purposes seegetColorObject()
.- Parameters:
color
-Color
object of the eitherDeviceGray
,DeviceRgb
orDeviceCmyk
type.- Returns:
- this
PdfAnnotation
instance.
-
getStructParentIndex
public int getStructParentIndex()
The integer key of the annotation’s entry in the structural parent tree (see ISO-320001 14.7.4.4, "Finding Structure Elements from Content Items").- Returns:
- integer key in structural parent tree or -1 if annotation is not tagged.
-
setStructParentIndex
public PdfAnnotation setStructParentIndex(int structParentIndex)
Sets he integer key of the annotation’s entry in the structural parent tree (see ISO-320001 14.7.4.4, "Finding Structure Elements from Content Items"). Note: Normally, there is no need to take care of this manually, struct parent index is set automatically if annotation is added to the tagged document's page.- Parameters:
structParentIndex
- integer which is to be the key of the annotation's entry in structural parent tree.- Returns:
- this
PdfAnnotation
instance.
-
setTitle
public PdfAnnotation setTitle(PdfString title)
Sets annotation title. This property affects not all annotation types.- Parameters:
title
- aPdfString
which value is to be annotation title.- Returns:
- this
PdfAnnotation
instance.
-
getTitle
public PdfString getTitle()
Annotation title. For example for markup annotations, the title is the text label that shall be displayed in the title bar of the annotation’s pop-up window when open and active. For movie annotation Movie actions (ISO-320001 12.6.4.9, "Movie Actions") may use this title to reference the movie annotation.- Returns:
PdfString
which value is an annotation title or null if it isn't specified.
-
setRectangle
public PdfAnnotation setRectangle(PdfArray array)
The annotation rectangle, defining the location of the annotation on the page in default user space units.- Parameters:
array
- aPdfArray
which specifies a rectangle by two diagonally opposite corners. Typically, the array is of form [llx lly urx ury].- Returns:
- this
PdfAnnotation
instance.
-
getRectangle
public PdfArray getRectangle()
The annotation rectangle, defining the location of the annotation on the page in default user space units.- Returns:
- a
PdfArray
which specifies a rectangle by two diagonally opposite corners. Typically, the array is of form [llx lly urx ury].
-
getLang
public java.lang.String getLang()
PDF 2.0. A language identifier overriding the document’s language identifier to specify the natural language for all text in the annotation except where overridden by other explicit language specifications- Returns:
- the lang entry
-
setLang
public PdfAnnotation setLang(java.lang.String lang)
PDF 2.0. A language identifier overriding the document’s language identifier to specify the natural language for all text in the annotation except where overridden by other explicit language specifications- Parameters:
lang
- language identifier- Returns:
- this
PdfAnnotation
instance
-
getBlendMode
public PdfName getBlendMode()
PDF 2.0. The blend mode that shall be used when painting the annotation onto the page- Returns:
- the blend mode
-
setBlendMode
public PdfAnnotation setBlendMode(PdfName blendMode)
PDF 2.0. The blend mode that shall be used when painting the annotation onto the page- Parameters:
blendMode
- blend mode- Returns:
- this
PdfAnnotation
instance
-
getNonStrokingOpacity
public float getNonStrokingOpacity()
PDF 2.0. When regenerating the annotation's appearance stream, this is the opacity value that shall be used for all nonstroking operations on all visible elements of the annotation in its closed state (including its background and border) but not the popup window that appears when the annotation is opened.- Returns:
- opacity value for nonstroking operations. Returns 1.0 (default value) if entry is not present
-
setNonStrokingOpacity
public PdfAnnotation setNonStrokingOpacity(float nonStrokingOpacity)
PDF 2.0. When regenerating the annotation's appearance stream, this is the opacity value that shall be used for all nonstroking operations on all visible elements of the annotation in its closed state (including its background and border) but not the popup window that appears when the annotation is opened.- Parameters:
nonStrokingOpacity
- opacity for nonstroking operations- Returns:
- this
PdfAnnotation
instance
-
getStrokingOpacity
public float getStrokingOpacity()
PDF 2.0. When regenerating the annotation's appearance stream, this is the opacity value that shall be used for stroking all visible elements of the annotation in its closed state, including its background and border, but not the popup window that appears when the annotation is opened.- Returns:
- opacity for stroking operations, including background and border
-
setStrokingOpacity
public PdfAnnotation setStrokingOpacity(float strokingOpacity)
PDF 2.0. When regenerating the annotation's appearance stream, this is the opacity value that shall be used for stroking all visible elements of the annotation in its closed state, including its background and border, but not the popup window that appears when the annotation is opened.- Parameters:
strokingOpacity
- opacity for stroking operations, including background and border- Returns:
- this
PdfAnnotation
object
-
put
public PdfAnnotation put(PdfName key, PdfObject value)
Inserts the value into into the underlyingPdfDictionary
of thisPdfAnnotation
and associates it with the specified key. If the key is already present in thisPdfAnnotation
, this method will override the old value with the specified one.- Parameters:
key
- key to insert or to overridevalue
- the value to associate with the specified key- Returns:
- this
PdfAnnotation
instance.
-
remove
public PdfAnnotation remove(PdfName key)
Removes the specified key from the underlyingPdfDictionary
of thisPdfAnnotation
.- Parameters:
key
- key to be removed- Returns:
- this
PdfAnnotation
instance.
-
addAssociatedFile
public void addAssociatedFile(PdfFileSpec fs)
Adds file associated with PDF annotation and identifies the relationship between them.
Associated files may be used in Pdf/A-3 and Pdf 2.0 documents. The method adds file to array value of the AF key in the annotation dictionary.
For associated files their associated file specification dictionaries shall include the AFRelationship key
- Parameters:
fs
- file specification dictionary of associated file
-
getAssociatedFiles
public PdfArray getAssociatedFiles(boolean create)
Returns files associated with PDF annotation.- Parameters:
create
- defines whether AF arrays will be created if it doesn't exist- Returns:
- associated files array
-
flush
public void flush()
To manually flush aPdfObject
behind this wrapper, you have to ensure that this object is added to the document, i.e. it has an indirect reference. Basically this means that before flushing you need to explicitly callPdfObjectWrapper.makeIndirect(PdfDocument)
. For example: wrapperInstance.makeIndirect(document).flush(); Note that not every wrapper require this, only those that have such warning in documentation.- Overrides:
flush
in classPdfObjectWrapper<PdfDictionary>
-
isWrappedObjectMustBeIndirect
protected boolean isWrappedObjectMustBeIndirect()
Description copied from class:PdfObjectWrapper
Defines if the object behind this wrapper must be an indirect object in the resultant document.
If this method returns true it doesn't necessarily mean that object must be in the indirect state at any moment, but rather defines that when the object will be written to the document it will be transformed into indirect object if it's not indirect yet.
Return value of this method shouldn't depend on any logic, it should return always true or false.- Specified by:
isWrappedObjectMustBeIndirect
in classPdfObjectWrapper<PdfDictionary>
- Returns:
- true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
-
-