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 classPdfAnnotation.PdfUnknownAnnotation
-
Field Summary
Fields Modifier and Type Field Description static PdfStringAcceptedAnnotation state.static PdfStringCanceledAnnotation state.static PdfStringCompletedAnnotation state.static intHIDDENAnnotation flag.static PdfNameHIGHLIGHT_INVERTWidget annotation highlighting mode.static PdfNameHIGHLIGHT_NONEWidget annotation highlighting mode.static PdfNameHIGHLIGHT_OUTLINEWidget annotation highlighting mode.static PdfNameHIGHLIGHT_PUSHWidget annotation highlighting mode.static PdfNameHIGHLIGHT_TOGGLEWidget annotation highlighting mode.static intINVISIBLEAnnotation flag.static intLOCKEDAnnotation flag.static intLOCKED_CONTENTSAnnotation flag.static PdfStringMarkedAnnotation state.static PdfStringMarkedModelAnnotation state model.static intNO_ROTATEAnnotation flag.static intNO_VIEWAnnotation flag.static intNO_ZOOMAnnotation flag.static PdfStringNoneAnnotation state.protected PdfPagepagestatic intPRINTAnnotation flag.static intREAD_ONLYAnnotation flag.static PdfStringRejectedAnnotation state.static PdfStringReviewModelAnnotation state model.static PdfNameSTYLE_BEVELEDAnnotation border style.static PdfNameSTYLE_DASHEDAnnotation border style.static PdfNameSTYLE_INSETAnnotation border style.static PdfNameSTYLE_SOLIDAnnotation border style.static PdfNameSTYLE_UNDERLINEAnnotation border style.static intTOGGLE_NO_VIEWAnnotation flag.static PdfStringUnmarkedAnnotation state.
-
Constructor Summary
Constructors Modifier Constructor Description protectedPdfAnnotation(Rectangle rect)protectedPdfAnnotation(PdfDictionary pdfObject)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddAssociatedFile(PdfFileSpec fs)Adds file associated with PDF annotation and identifies the relationship between them.voidflush()To manually flush aPdfObjectbehind this wrapper, you have to ensure that this object is added to the document, i.e.PdfDictionarygetAppearanceDictionary()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").PdfDictionarygetAppearanceObject(PdfName appearanceType)Specific appearance object corresponding to the specific appearance type.PdfNamegetAppearanceState()The annotation’s appearance state, which selects the applicable appearance stream from an appearance subdictionary if there is such.PdfArraygetAssociatedFiles(boolean create)Returns files associated with PDF annotation.PdfNamegetBlendMode()PDF 2.0.PdfArraygetBorder()An array specifying the characteristics of the annotation’s border.PdfArraygetColorObject()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 - DeviceCMYKPdfStringgetContents()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.PdfStringgetDate()The date and time when the annotation was most recently modified.PdfDictionarygetDownAppearanceObject()The down appearance is used when the mouse button is pressed or held down within the annotation’s active area.intgetFlags()A set of flags specifying various characteristics of the annotation (see ISO-320001 12.5.3, "Annotation Flags").java.lang.StringgetLang()PDF 2.0.PdfStringgetName()Gets the annotation name, a text string uniquely identifying it among all the annotations on its page.floatgetNonStrokingOpacity()PDF 2.0.PdfDictionarygetNormalAppearanceObject()The normal appearance is used when the annotation is not interacting with the user.PdfPagegetPage()Gets aPdfPageon which annotation is placed.PdfDictionarygetPageObject()Gets aPdfDictionarythat represents a page of the document on which annotation is placed, i.e.PdfArraygetRectangle()The annotation rectangle, defining the location of the annotation on the page in default user space units.PdfDictionarygetRolloverAppearanceObject()The rollover appearance is used when the user moves the cursor into the annotation’s active area without pressing the mouse button.floatgetStrokingOpacity()PDF 2.0.intgetStructParentIndex()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 PdfNamegetSubtype()Gets aPdfNamewhich value is a subtype of this annotation.PdfStringgetTitle()Annotation title.booleanhasFlag(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 booleanisWrappedObjectMustBeIndirect()Defines if the object behind this wrapper must be an indirect object in the resultant document.static PdfAnnotationmakeAnnotation(PdfObject pdfObject)Factory method that creates the type specificPdfAnnotationfrom the givenPdfObjectthat represents annotation object.PdfAnnotationput(PdfName key, PdfObject value)Inserts the value into into the underlyingPdfDictionaryof thisPdfAnnotationand associates it with the specified key.PdfAnnotationremove(PdfName key)Removes the specified key from the underlyingPdfDictionaryof thisPdfAnnotation.PdfAnnotationresetFlag(int flag)Resets a flag that specifies a characteristic of the annotation to disabled state (see ISO-320001 12.5.3, "Annotation Flags").PdfAnnotationsetAppearance(PdfName appearanceType, PdfAnnotationAppearance appearance)Sets a specific type of the appearance usingPdfAnnotationAppearancewrapper.PdfAnnotationsetAppearance(PdfName appearanceType, PdfDictionary appearance)Sets a specific type of the appearance.PdfAnnotationsetAppearanceState(PdfName as)Sets the annotation’s appearance state, which selects the applicable appearance stream from an appearance subdictionary.PdfAnnotationsetBlendMode(PdfName blendMode)PDF 2.0.PdfAnnotationsetBorder(PdfAnnotationBorder border)Sets the characteristics of the annotation’s border.PdfAnnotationsetBorder(PdfArray border)Sets the characteristics of the annotation’s border.PdfAnnotationsetColor(float[] color)Sets an annotation color.PdfAnnotationsetColor(Color color)Sets an annotation color.PdfAnnotationsetColor(PdfArray color)Sets an annotation color.PdfAnnotationsetContents(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.PdfAnnotationsetContents(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.PdfAnnotationsetDate(PdfString date)The date and time when the annotation was most recently modified.PdfAnnotationsetDownAppearance(PdfAnnotationAppearance appearance)Sets down appearance usingPdfAnnotationAppearancewrapper.PdfAnnotationsetDownAppearance(PdfDictionary appearance)Sets down appearance.PdfAnnotationsetFlag(int flag)Sets a flag that specifies a characteristic of the annotation to enabled state (see ISO-320001 12.5.3, "Annotation Flags").PdfAnnotationsetFlags(int flags)Sets a set of flags specifying various characteristics of the annotation (see ISO-320001 12.5.3, "Annotation Flags").PdfAnnotationsetLang(java.lang.String lang)PDF 2.0.voidsetLayer(IPdfOCG layer)Sets the layer this annotation belongs to.PdfAnnotationsetName(PdfString name)Sets the annotation name, a text string uniquely identifying it among all the annotations on its page.PdfAnnotationsetNonStrokingOpacity(float nonStrokingOpacity)PDF 2.0.PdfAnnotationsetNormalAppearance(PdfAnnotationAppearance appearance)Sets normal appearance usingPdfAnnotationAppearancewrapper.PdfAnnotationsetNormalAppearance(PdfDictionary appearance)Sets normal appearance.PdfAnnotationsetPage(PdfPage page)Method that modifies annotation page property, which defines to which page annotation belongs.PdfAnnotationsetRectangle(PdfArray array)The annotation rectangle, defining the location of the annotation on the page in default user space units.PdfAnnotationsetRolloverAppearance(PdfAnnotationAppearance appearance)Sets rollover appearance usingPdfAnnotationAppearancewrapper.PdfAnnotationsetRolloverAppearance(PdfDictionary appearance)Sets rollover appearance.PdfAnnotationsetStrokingOpacity(float strokingOpacity)PDF 2.0.PdfAnnotationsetStructParentIndex(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").PdfAnnotationsetTitle(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 specificPdfAnnotationfrom the givenPdfObjectthat 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- aPdfObjectthat represents annotation in the document.- Returns:
- created
PdfAnnotation.
-
getSubtype
public abstract PdfName getSubtype()
Gets aPdfNamewhich 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- aPdfStringcontaining text content to be set to the annotation.- Returns:
- this
PdfAnnotationinstance.
-
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 javaStringcontaining text content to be set to the annotation.- Returns:
- this
PdfAnnotationinstance.
-
getPageObject
public PdfDictionary getPageObject()
Gets aPdfDictionarythat represents a page of the document on which annotation is placed, i.e. which has this annotation in it's /Annots array.- Returns:
PdfDictionarythat is a page pdf object or null if annotation is not added to the page yet.
-
getPage
public PdfPage getPage()
Gets aPdfPageon which annotation is placed.- Returns:
PdfPageon 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- thePdfPageto which annotation will be added.- Returns:
- this
PdfAnnotationinstance.
-
getName
public PdfString getName()
Gets the annotation name, a text string uniquely identifying it among all the annotations on its page.- Returns:
- a
PdfStringwith 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- aPdfStringto be set as annotation name.- Returns:
- this
PdfAnnotationinstance.
-
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
PdfStringwith 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- aPdfStringwith date. The format should be a date string as described in ISO-320001 7.9.4, "Dates".- Returns:
- this
PdfAnnotationinstance.
-
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
PdfAnnotationinstance.
-
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
PdfAnnotationinstance.
-
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
PdfAnnotationinstance.
-
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
PdfDictionaryor 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- aPdfNamespecifying appearance type. Possible types areNormal,RolloverandDown.appearance- an appearance object which might be either an appearance stream or an appearance subdictionary.- Returns:
- this
PdfAnnotationinstance.
-
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
PdfAnnotationinstance.
-
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
PdfAnnotationinstance.
-
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
PdfAnnotationinstance.
-
setAppearance
public PdfAnnotation setAppearance(PdfName appearanceType, PdfAnnotationAppearance appearance)
Sets a specific type of the appearance usingPdfAnnotationAppearancewrapper. This method is used to set only an appearance subdictionary. SeegetAppearanceObject(PdfName)andgetAppearanceDictionary()for more info.- Parameters:
appearanceType- aPdfNamespecifying appearance type. Possible types areNormal,RolloverandDown.appearance- an appearance subdictionary wrapped inPdfAnnotationAppearance.- Returns:
- this
PdfAnnotationinstance.
-
setNormalAppearance
public PdfAnnotation setNormalAppearance(PdfAnnotationAppearance appearance)
Sets normal appearance usingPdfAnnotationAppearancewrapper. This method is used to set only appearance subdictionary. SeegetNormalAppearanceObject()andgetAppearanceDictionary()for more info.- Parameters:
appearance- an appearance subdictionary wrapped inPdfAnnotationAppearance.- Returns:
- this
PdfAnnotationinstance.
-
setRolloverAppearance
public PdfAnnotation setRolloverAppearance(PdfAnnotationAppearance appearance)
Sets rollover appearance usingPdfAnnotationAppearancewrapper. This method is used to set only appearance subdictionary. SeegetRolloverAppearanceObject()andgetAppearanceDictionary()for more info.- Parameters:
appearance- an appearance subdictionary wrapped inPdfAnnotationAppearance.- Returns:
- this
PdfAnnotationinstance.
-
setDownAppearance
public PdfAnnotation setDownAppearance(PdfAnnotationAppearance appearance)
Sets down appearance usingPdfAnnotationAppearancewrapper. This method is used to set only appearance subdictionary. SeegetDownAppearanceObject()andgetAppearanceDictionary()for more info.- Parameters:
appearance- an appearance subdictionary wrapped inPdfAnnotationAppearance.- Returns:
- this
PdfAnnotationinstance.
-
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
PdfNamewhich 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- aPdfNamewhich defines appearance state to be selected.- Returns:
- this
PdfAnnotationinstance.
-
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
PdfArrayspecifying the characteristics of the annotation’s border.
-
setBorder
public PdfAnnotation setBorder(PdfAnnotationBorder border)
Sets the characteristics of the annotation’s border.- Parameters:
border- anPdfAnnotationBorderspecifying the characteristics of the annotation’s border. SeegetBorder()for more detailes.- Returns:
- this
PdfAnnotationinstance.
-
setBorder
public PdfAnnotation setBorder(PdfArray border)
Sets the characteristics of the annotation’s border.- Parameters:
border- anPdfArrayspecifying the characteristics of the annotation’s border. SeegetBorder()for more detailes.- Returns:
- this
PdfAnnotationinstance.
-
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 passingPdfArrayseegetColorObject().- Parameters:
color- an array of numbers in the range 0.0 to 1.0, specifying color.- Returns:
- this
PdfAnnotationinstance.
-
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
PdfAnnotationinstance.
-
setColor
public PdfAnnotation setColor(Color color)
Sets an annotation color. For more details on annotation color purposes seegetColorObject().- Parameters:
color-Colorobject of the eitherDeviceGray,DeviceRgborDeviceCmyktype.- Returns:
- this
PdfAnnotationinstance.
-
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
PdfAnnotationinstance.
-
setTitle
public PdfAnnotation setTitle(PdfString title)
Sets annotation title. This property affects not all annotation types.- Parameters:
title- aPdfStringwhich value is to be annotation title.- Returns:
- this
PdfAnnotationinstance.
-
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:
PdfStringwhich 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- aPdfArraywhich specifies a rectangle by two diagonally opposite corners. Typically, the array is of form [llx lly urx ury].- Returns:
- this
PdfAnnotationinstance.
-
getRectangle
public PdfArray getRectangle()
The annotation rectangle, defining the location of the annotation on the page in default user space units.- Returns:
- a
PdfArraywhich 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
PdfAnnotationinstance
-
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
PdfAnnotationinstance
-
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
PdfAnnotationinstance
-
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
PdfAnnotationobject
-
put
public PdfAnnotation put(PdfName key, PdfObject value)
Inserts the value into into the underlyingPdfDictionaryof thisPdfAnnotationand 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
PdfAnnotationinstance.
-
remove
public PdfAnnotation remove(PdfName key)
Removes the specified key from the underlyingPdfDictionaryof thisPdfAnnotation.- Parameters:
key- key to be removed- Returns:
- this
PdfAnnotationinstance.
-
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 aPdfObjectbehind 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:
flushin classPdfObjectWrapper<PdfDictionary>
-
isWrappedObjectMustBeIndirect
protected boolean isWrappedObjectMustBeIndirect()
Description copied from class:PdfObjectWrapperDefines 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:
isWrappedObjectMustBeIndirectin classPdfObjectWrapper<PdfDictionary>- Returns:
- true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
-
-