Class PDAnnotation
java.lang.Object
org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation
- All Implemented Interfaces:
COSObjectable
- Direct Known Subclasses:
PDAnnotationLink
,PDAnnotationMarkup
,PDAnnotationPopup
,PDAnnotationUnknown
,PDAnnotationWidget
This class represents a PDF annotation.
- Author:
- Ben Litchfield
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
An annotation flag.static final int
An annotation flag.static final int
An annotation flag.static final int
An annotation flag.static final int
An annotation flag.static final int
An annotation flag.static final int
An annotation flag.static final int
An annotation flag.static final int
An annotation flag. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PDAnnotation
createAnnotation
(COSBase base) Create the correct annotation from the base COS object.int
This will get the flags for this field.This will get the name, a string intended to uniquely identify each annotation within a page.This will get the appearance dictionary associated with this annotation.This will get the name of the current appearance stream if any.This will retrieve the colour used in drawing various elements.Get the "contents" of the field.Interface method for COSObjectable.returns the dictionary.This will retrieve the date and time the annotation was modified.getPage()
This will retrieve the corresponding page of this annotation.The annotation rectangle, defining the location of the annotation on the page in default user space units.int
This will get the key of this annotation in the structural parent tree.This will retrieve the subtype of the annotation.boolean
isHidden()
Get the hidden flag.boolean
Get the invisible flag.boolean
isLocked()
Get the locked flag.boolean
Get the noRotate flag.boolean
isNoView()
Get the noView flag.boolean
isNoZoom()
Get the noZoom flag.boolean
Get the printed flag.boolean
Get the readOnly flag.boolean
Get the toggleNoView flag.void
setAnnotationFlags
(int flags) This will set the flags for this field.void
This will set the name, a string intended to uniquely identify each annotation within a page.void
setAppearance
(PDAppearanceDictionary appearance) This will set the appearance associated with this annotation.void
This will set the annotations appearance stream name.void
This will set the colour used in drawing various elements.void
setContents
(String value) Set the "contents" of the field.void
setHidden
(boolean hidden) Set the hidden flag.void
setInvisible
(boolean invisible) Set the invisible flag.void
setLocked
(boolean locked) Set the locked flag.void
This will set the date and time the annotation was modified.void
This will set the date and time the annotation was modified.void
setNoRotate
(boolean noRotate) Set the noRotate flag.void
setNoView
(boolean noView) Set the noView flag.void
setNoZoom
(boolean noZoom) Set the noZoom flag.void
This will set the corresponding page for this annotation.void
setPrinted
(boolean printed) Set the printed flag.void
setReadOnly
(boolean readOnly) Set the readOnly flag.void
setRectangle
(PDRectangle rectangle) This will set the rectangle for this annotation.void
setStructParent
(int structParent) This will set the key for this annotation in the structural parent tree.void
setToggleNoView
(boolean toggleNoView) Set the toggleNoView flag.
-
Field Details
-
FLAG_INVISIBLE
public static final int FLAG_INVISIBLEAn annotation flag.- See Also:
-
FLAG_HIDDEN
public static final int FLAG_HIDDENAn annotation flag.- See Also:
-
FLAG_PRINTED
public static final int FLAG_PRINTEDAn annotation flag.- See Also:
-
FLAG_NO_ZOOM
public static final int FLAG_NO_ZOOMAn annotation flag.- See Also:
-
FLAG_NO_ROTATE
public static final int FLAG_NO_ROTATEAn annotation flag.- See Also:
-
FLAG_NO_VIEW
public static final int FLAG_NO_VIEWAn annotation flag.- See Also:
-
FLAG_READ_ONLY
public static final int FLAG_READ_ONLYAn annotation flag.- See Also:
-
FLAG_LOCKED
public static final int FLAG_LOCKEDAn annotation flag.- See Also:
-
FLAG_TOGGLE_NO_VIEW
public static final int FLAG_TOGGLE_NO_VIEWAn annotation flag.- See Also:
-
-
Constructor Details
-
PDAnnotation
public PDAnnotation()Constructor. -
PDAnnotation
Constructor.- Parameters:
dict
- The annotations dictionary.
-
-
Method Details
-
createAnnotation
Create the correct annotation from the base COS object.- Parameters:
base
- The COS object that is the annotation.- Returns:
- The correctly typed annotation object.
- Throws:
IOException
- If the annotation type is unknown.
-
getDictionary
returns the dictionary.- Returns:
- the dictionary
-
getRectangle
The annotation rectangle, defining the location of the annotation on the page in default user space units. This is usually required and should not return null on valid PDF documents. But where this is a parent form field with children, such as radio button collections then the rectangle will be null.- Returns:
- The Rect value of this annotation.
-
setRectangle
This will set the rectangle for this annotation.- Parameters:
rectangle
- The new rectangle values.
-
getAnnotationFlags
public int getAnnotationFlags()This will get the flags for this field.- Returns:
- flags The set of flags.
-
setAnnotationFlags
public void setAnnotationFlags(int flags) This will set the flags for this field.- Parameters:
flags
- The new flags.
-
getCOSObject
Interface method for COSObjectable.- Specified by:
getCOSObject
in interfaceCOSObjectable
- Returns:
- This object as a standard COS object.
-
getAppearanceStream
This will get the name of the current appearance stream if any.- Returns:
- The name of the appearance stream.
-
setAppearanceStream
This will set the annotations appearance stream name.- Parameters:
as
- The name of the appearance stream.
-
getAppearance
This will get the appearance dictionary associated with this annotation. This may return null.- Returns:
- This annotations appearance.
-
setAppearance
This will set the appearance associated with this annotation.- Parameters:
appearance
- The appearance dictionary for this annotation.
-
isInvisible
public boolean isInvisible()Get the invisible flag.- Returns:
- The invisible flag.
-
setInvisible
public void setInvisible(boolean invisible) Set the invisible flag.- Parameters:
invisible
- The new invisible flag.
-
isHidden
public boolean isHidden()Get the hidden flag.- Returns:
- The hidden flag.
-
setHidden
public void setHidden(boolean hidden) Set the hidden flag.- Parameters:
hidden
- The new hidden flag.
-
isPrinted
public boolean isPrinted()Get the printed flag.- Returns:
- The printed flag.
-
setPrinted
public void setPrinted(boolean printed) Set the printed flag.- Parameters:
printed
- The new printed flag.
-
isNoZoom
public boolean isNoZoom()Get the noZoom flag.- Returns:
- The noZoom flag.
-
setNoZoom
public void setNoZoom(boolean noZoom) Set the noZoom flag.- Parameters:
noZoom
- The new noZoom flag.
-
isNoRotate
public boolean isNoRotate()Get the noRotate flag.- Returns:
- The noRotate flag.
-
setNoRotate
public void setNoRotate(boolean noRotate) Set the noRotate flag.- Parameters:
noRotate
- The new noRotate flag.
-
isNoView
public boolean isNoView()Get the noView flag.- Returns:
- The noView flag.
-
setNoView
public void setNoView(boolean noView) Set the noView flag.- Parameters:
noView
- The new noView flag.
-
isReadOnly
public boolean isReadOnly()Get the readOnly flag.- Returns:
- The readOnly flag.
-
setReadOnly
public void setReadOnly(boolean readOnly) Set the readOnly flag.- Parameters:
readOnly
- The new readOnly flag.
-
isLocked
public boolean isLocked()Get the locked flag.- Returns:
- The locked flag.
-
setLocked
public void setLocked(boolean locked) Set the locked flag.- Parameters:
locked
- The new locked flag.
-
isToggleNoView
public boolean isToggleNoView()Get the toggleNoView flag.- Returns:
- The toggleNoView flag.
-
setToggleNoView
public void setToggleNoView(boolean toggleNoView) Set the toggleNoView flag.- Parameters:
toggleNoView
- The new toggleNoView flag.
-
getContents
Get the "contents" of the field.- Returns:
- the value of the contents.
-
setContents
Set the "contents" of the field.- Parameters:
value
- the value of the contents.
-
getModifiedDate
This will retrieve the date and time the annotation was modified.- Returns:
- the modified date/time (often in date format, but can be an arbitary string).
-
setModifiedDate
This will set the date and time the annotation was modified.- Parameters:
m
- the date and time the annotation was created. Date values used in a PDF shall conform to a standard date format, which closely follows that of the international standard ASN.1 (Abstract Syntax Notation One), defined in ISO/IEC 8824. A date shall be a text string of the form (D:YYYYMMDDHHmmSSOHH'mm). Alternatively, usesetModifiedDate(java.util.Calendar)
-
setModifiedDate
This will set the date and time the annotation was modified.- Parameters:
c
- the date and time the annotation was created.
-
getAnnotationName
This will get the name, a string intended to uniquely identify each annotation within a page. Not to be confused with some annotations Name entry which impact the default image drawn for them.- Returns:
- The identifying name for the Annotation.
-
setAnnotationName
This will set the name, a string intended to uniquely identify each annotation within a page. Not to be confused with some annotations Name entry which impact the default image drawn for them.- Parameters:
nm
- The identifying name for the annotation.
-
getStructParent
public int getStructParent()This will get the key of this annotation in the structural parent tree.- Returns:
- the integer key of the annotation's entry in the structural parent tree
-
setStructParent
public void setStructParent(int structParent) This will set the key for this annotation in the structural parent tree.- Parameters:
structParent
- The new key for this annotation.
-
setColour
This will set the colour used in drawing various elements. As of PDF 1.6 these are : Background of icon when closed Title bar of popup window Border of a link annotation Colour is in DeviceRGB colourspace- Parameters:
c
- colour in the DeviceRGB colourspace
-
getColour
This will retrieve the colour used in drawing various elements. As of PDF 1.6 these are : Background of icon when closed Title bar of popup window Border of a link annotation Colour is in DeviceRGB colourspace- Returns:
- PDGamma object representing the colour
-
getSubtype
This will retrieve the subtype of the annotation.- Returns:
- the subtype
-
setPage
This will set the corresponding page for this annotation.- Parameters:
page
- is the corresponding page
-
getPage
This will retrieve the corresponding page of this annotation.- Returns:
- the corresponding page
-