public abstract class PdfAnnotation extends PdfObjectWrapper<PdfDictionary>
Modifier and Type | Field and 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.
|
Modifier | Constructor and Description |
---|---|
protected |
PdfAnnotation(PdfDictionary pdfObject) |
protected |
PdfAnnotation(Rectangle rect) |
Modifier and Type | Method and Description |
---|---|
void |
addAssociatedFile(PdfFileSpec fs)
Adds file associated with PDF annotation and identifies the relationship between them.
|
void |
flush()
To manually flush a PdfObject 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 - DeviceCMYK
|
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.
|
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").
|
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 a PdfPage on which annotation is placed.
|
PdfDictionary |
getPageObject()
Gets a PdfDictionary 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 a PdfName 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 specific PdfAnnotation from the given PdfObject that represents annotation object.
|
PdfAnnotation |
put(PdfName key, PdfObject value)
Inserts the value into into the underlying PdfDictionary of this PdfAnnotation and associates it with the specified key.
|
PdfAnnotation |
remove(PdfName key)
Removes the specified key from the underlying PdfDictionary of this PdfAnnotation .
|
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 using PdfAnnotationAppearance 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(Color color)
Sets an annotation color.
|
PdfAnnotation |
setColor(float[] 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(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 using PdfAnnotationAppearance 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(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 using PdfAnnotationAppearance 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 using PdfAnnotationAppearance 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.
|
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
public static final int INVISIBLE
setFlag(int)
and ISO-320001, table 165.
public static final int HIDDEN
setFlag(int)
and ISO-320001, table 165.
public static final int PRINT
setFlag(int)
and ISO-320001, table 165.
public static final int NO_ZOOM
setFlag(int)
and ISO-320001, table 165.
public static final int NO_ROTATE
setFlag(int)
and ISO-320001, table 165.
public static final int NO_VIEW
setFlag(int)
and ISO-320001, table 165.
public static final int READ_ONLY
setFlag(int)
and ISO-320001, table 165.
public static final int LOCKED
setFlag(int)
and ISO-320001, table 165.
public static final int TOGGLE_NO_VIEW
setFlag(int)
and ISO-320001, table 165.
public static final int LOCKED_CONTENTS
setFlag(int)
and ISO-320001, table 165.
public static final PdfName HIGHLIGHT_NONE
PdfWidgetAnnotation.setHighlightMode(PdfName)
.
public static final PdfName HIGHLIGHT_INVERT
PdfWidgetAnnotation.setHighlightMode(PdfName)
.
public static final PdfName HIGHLIGHT_OUTLINE
PdfWidgetAnnotation.setHighlightMode(PdfName)
.
public static final PdfName HIGHLIGHT_PUSH
PdfWidgetAnnotation.setHighlightMode(PdfName)
.
public static final PdfName HIGHLIGHT_TOGGLE
PdfWidgetAnnotation.setHighlightMode(PdfName)
.
public static final PdfName STYLE_SOLID
public static final PdfName STYLE_DASHED
public static final PdfName STYLE_BEVELED
public static final PdfName STYLE_INSET
public static final PdfName STYLE_UNDERLINE
public static final PdfString Marked
PdfTextAnnotation.setState(PdfString)
.
public static final PdfString Unmarked
PdfTextAnnotation.setState(PdfString)
.
public static final PdfString Accepted
PdfTextAnnotation.setState(PdfString)
.
public static final PdfString Rejected
PdfTextAnnotation.setState(PdfString)
.
public static final PdfString Canceled
PdfTextAnnotation.setState(PdfString)
.
public static final PdfString Completed
PdfTextAnnotation.setState(PdfString)
.
public static final PdfString None
PdfTextAnnotation.setState(PdfString)
.
public static final PdfString MarkedModel
PdfTextAnnotation.setStateModel(PdfString)
.
public static final PdfString ReviewModel
PdfTextAnnotation.setStateModel(PdfString)
.
protected PdfPage page
protected PdfAnnotation(Rectangle rect)
protected PdfAnnotation(PdfDictionary pdfObject)
public static PdfAnnotation makeAnnotation(PdfObject pdfObject)
PdfAnnotation
from the given PdfObject
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.
pdfObject
- a PdfObject
that represents annotation in the document.
PdfAnnotation
.
public abstract PdfName getSubtype()
PdfName
which value is a subtype of this annotation. See ISO-320001 12.5.6, "Annotation Types" for the reference to the possible types.
public void setLayer(IPdfOCG layer)
layer
- the layer this annotation belongs to
public PdfString getContents()
public PdfAnnotation setContents(PdfString contents)
contents
- a PdfString
containing text content to be set to the annotation.
PdfAnnotation
instance.
public PdfAnnotation setContents(String contents)
contents
- a java String
containing text content to be set to the annotation.
PdfAnnotation
instance.
public PdfDictionary getPageObject()
PdfDictionary
that represents a page of the document on which annotation is placed, i.e. which has this annotation in it's /Annots array.
PdfDictionary
that is a page pdf object or null if annotation is not added to the page yet.
public PdfPage getPage()
PdfPage
on which annotation is placed.
PdfPage
on which annotation is placed or null if annotation is not placed yet.
public PdfAnnotation setPage(PdfPage page)
PdfPage.addAnnotation(PdfAnnotation)
. Also you don't need to set this property manually, this is done automatically on addition to the page.
page
- the PdfPage
to which annotation will be added.
PdfAnnotation
instance.
public PdfString getName()
PdfString
with annotation name as it's value or null if name is not specified.
public PdfAnnotation setName(PdfString name)
name
- a PdfString
to be set as annotation name.
PdfAnnotation
instance.
public PdfString getDate()
PdfString
with the modification date as it's value or null if date is not specified.
public PdfAnnotation setDate(PdfString date)
date
- a PdfString
with date. The format should be a date string as described in ISO-320001 7.9.4, "Dates".
PdfAnnotation
instance.
public int getFlags()
setFlag(int)
. Default value: 0.
public PdfAnnotation setFlags(int flags)
setFlag(int)
, this method sets a complete set of enabled and disabled flags at once. If not set specifically the default value is 0.
flags
- an integer interpreted as set of one-bit flags specifying various characteristics of the annotation.
PdfAnnotation
instance.
public PdfAnnotation setFlag(int flag)
setFlags(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. flag
- - an integer interpreted as set of one-bit flags which will be enabled for this annotation.
PdfAnnotation
instance.
public PdfAnnotation resetFlag(int flag)
flag
- an integer interpreted as set of one-bit flags which will be reset to disabled state.
PdfAnnotation
instance.
public boolean hasFlag(int flag)
setFlag(int)
.
flag
- an integer interpreted as set of one-bit flags. Only one bit must be set in this integer, otherwise exception is thrown.
public PdfDictionary getAppearanceDictionary()
PdfDictionary
or null if it is not specified.
public PdfDictionary getAppearanceObject(PdfName appearanceType)
public PdfDictionary getNormalAppearanceObject()
getAppearanceObject(PdfName)
.
public PdfDictionary getRolloverAppearanceObject()
getAppearanceObject(PdfName)
.
public PdfDictionary getDownAppearanceObject()
getAppearanceObject(PdfName)
.
public PdfAnnotation setAppearance(PdfName appearanceType, PdfDictionary appearance)
getAppearanceObject(PdfName)
and getAppearanceDictionary()
for more info.
appearanceType
- a PdfName
specifying appearance type. Possible types are Normal
, Rollover
and Down
.
appearance
- an appearance object which might be either an appearance stream or an appearance subdictionary.
PdfAnnotation
instance.
public PdfAnnotation setNormalAppearance(PdfDictionary appearance)
getNormalAppearanceObject()
and getAppearanceDictionary()
for more info.
appearance
- an appearance object which might be either an appearance stream or an appearance subdictionary.
PdfAnnotation
instance.
public PdfAnnotation setRolloverAppearance(PdfDictionary appearance)
getRolloverAppearanceObject()
and getAppearanceDictionary()
for more info.
appearance
- an appearance object which might be either an appearance stream or an appearance subdictionary.
PdfAnnotation
instance.
public PdfAnnotation setDownAppearance(PdfDictionary appearance)
getDownAppearanceObject()
and getAppearanceDictionary()
for more info.
appearance
- an appearance object which might be either an appearance stream or an appearance subdictionary.
PdfAnnotation
instance.
public PdfAnnotation setAppearance(PdfName appearanceType, PdfAnnotationAppearance appearance)
PdfAnnotationAppearance
wrapper. This method is used to set only an appearance subdictionary. See getAppearanceObject(PdfName)
and getAppearanceDictionary()
for more info.
appearanceType
- a PdfName
specifying appearance type. Possible types are Normal
, Rollover
and Down
.
appearance
- an appearance subdictionary wrapped in PdfAnnotationAppearance
.
PdfAnnotation
instance.
public PdfAnnotation setNormalAppearance(PdfAnnotationAppearance appearance)
PdfAnnotationAppearance
wrapper. This method is used to set only appearance subdictionary. See getNormalAppearanceObject()
and getAppearanceDictionary()
for more info.
appearance
- an appearance subdictionary wrapped in PdfAnnotationAppearance
.
PdfAnnotation
instance.
public PdfAnnotation setRolloverAppearance(PdfAnnotationAppearance appearance)
PdfAnnotationAppearance
wrapper. This method is used to set only appearance subdictionary. See getRolloverAppearanceObject()
and getAppearanceDictionary()
for more info.
appearance
- an appearance subdictionary wrapped in PdfAnnotationAppearance
.
PdfAnnotation
instance.
public PdfAnnotation setDownAppearance(PdfAnnotationAppearance appearance)
PdfAnnotationAppearance
wrapper. This method is used to set only appearance subdictionary. See getDownAppearanceObject()
and getAppearanceDictionary()
for more info.
appearance
- an appearance subdictionary wrapped in PdfAnnotationAppearance
.
PdfAnnotation
instance.
public PdfName getAppearanceState()
getAppearanceObject(PdfName)
for more info.
PdfName
which defines selected appearance state.
public PdfAnnotation setAppearanceState(PdfName as)
getAppearanceObject(PdfName)
for more info.
as
- a PdfName
which defines appearance state to be selected.
PdfAnnotation
instance.
public PdfArray getBorder()
The array may have a fourth element, an optional dash array (see ISO-320001 8.4.3.6, "Line Dash Pattern").
PdfArray
specifying the characteristics of the annotation’s border.
public PdfAnnotation setBorder(PdfAnnotationBorder border)
border
- an PdfAnnotationBorder
specifying the characteristics of the annotation’s border. See getBorder()
for more detailes.
PdfAnnotation
instance.
public PdfAnnotation setBorder(PdfArray border)
border
- an PdfArray
specifying the characteristics of the annotation’s border. See getBorder()
for more detailes.
PdfAnnotation
instance.
public PdfArray getColorObject()
public PdfAnnotation setColor(PdfArray color)
PdfArray
see getColorObject()
.
color
- an array of numbers in the range 0.0 to 1.0, specifying color.
PdfAnnotation
instance.
public PdfAnnotation setColor(float[] color)
getColorObject()
.
color
- an array of numbers in the range 0.0 to 1.0, specifying color.
PdfAnnotation
instance.
public PdfAnnotation setColor(Color color)
getColorObject()
.
color
- Color
object of the either DeviceGray
, DeviceRgb
or DeviceCmyk
type.
PdfAnnotation
instance.
public int getStructParentIndex()
public PdfAnnotation setStructParentIndex(int structParentIndex)
structParentIndex
- integer which is to be the key of the annotation's entry in structural parent tree.
PdfAnnotation
instance.
public PdfAnnotation setTitle(PdfString title)
title
- a PdfString
which value is to be annotation title.
PdfAnnotation
instance.
public PdfString getTitle()
PdfString
which value is an annotation title or null if it isn't specified.
public PdfAnnotation setRectangle(PdfArray array)
array
- a PdfArray
which specifies a rectangle by two diagonally opposite corners. Typically, the array is of form [llx lly urx ury].
PdfAnnotation
instance.
public PdfArray getRectangle()
PdfArray
which specifies a rectangle by two diagonally opposite corners. Typically, the array is of form [llx lly urx ury].
public String getLang()
public PdfAnnotation setLang(String lang)
lang
- language identifier
PdfAnnotation
instance
public PdfName getBlendMode()
public PdfAnnotation setBlendMode(PdfName blendMode)
blendMode
- blend mode
PdfAnnotation
instance
public float getNonStrokingOpacity()
public PdfAnnotation setNonStrokingOpacity(float nonStrokingOpacity)
nonStrokingOpacity
- opacity for nonstroking operations
PdfAnnotation
instance
public float getStrokingOpacity()
public PdfAnnotation setStrokingOpacity(float strokingOpacity)
strokingOpacity
- opacity for stroking operations, including background and border
PdfAnnotation
object
public PdfAnnotation put(PdfName key, PdfObject value)
PdfDictionary
of this PdfAnnotation
and associates it with the specified key. If the key is already present in this PdfAnnotation
, this method will override the old value with the specified one.
key
- key to insert or to override
value
- the value to associate with the specified key
PdfAnnotation
instance.
public PdfAnnotation remove(PdfName key)
PdfDictionary
of this PdfAnnotation
.
key
- key to be removed
PdfAnnotation
instance.
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
fs
- file specification dictionary of associated file
public PdfArray getAssociatedFiles(boolean create)
create
- defines whether AF arrays will be created if it doesn't exist
public void flush()
PdfObject
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 call PdfObjectWrapper.makeIndirect(PdfDocument)
. For example: wrapperInstance.makeIndirect(document).flush(); Note that not every wrapper require this, only those that have such warning in documentation.
flush
in class PdfObjectWrapper<PdfDictionary>
protected boolean isWrappedObjectMustBeIndirect()
PdfObjectWrapper
isWrappedObjectMustBeIndirect
in class PdfObjectWrapper<PdfDictionary>
Copyright © 1998–2023 iText Group NV. All rights reserved.