Class PDAnnotationMarkup
java.lang.Object
org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation
org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup
- All Implemented Interfaces:
COSObjectable
- Direct Known Subclasses:
PDAnnotationFileAttachment
,PDAnnotationLine
,PDAnnotationRubberStamp
,PDAnnotationSquareCircle
,PDAnnotationText
,PDAnnotationTextMarkup
This class represents the additional fields of a Markup type Annotation. See section 12.5.6 of ISO32000-1:2008
(starting with page 390) for details on annotation types.
- Author:
- Paul King
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
A plain free-text annotation, also known as a text box comment.static final String
A callout, associated with an area on the page through the callout line specified.static final String
The annotation is intended to function as a click-to-type or typewriter object.static final String
Constant for an annotation reply type.static final String
Constant for an annotation reply type.static final String
Constant for an Caret type of annotation.static final String
Constant for a FreeText type of annotation.static final String
Constant for an Ink type of annotation.static final String
Constant for an Polygon type of annotation.static final String
Constant for an PolyLine type of annotation.static final String
Constant for an Sound type of annotation. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Create the appearance entry for this annotation.void
constructAppearances
(PDDocument document) Create the appearance entry for this annotation.This will retrieve the border effect dictionary, specifying effects to be applied used in drawing the line.This will retrieve the border style dictionary, specifying the width and dash pattern used in drawing the line.float[]
This will get the coordinates of the callout line.float
This will retrieve the constant opacity value used when rendering the annotation (excluing any popup).This will retrieve the date and time the annotation was created.Get the default appearance.Get the default style string.This will retrieve the line ending style for the end point, possible values shown in the LE_ constants section.This will return the external data dictionary.float[][]
Get one or more disjoint paths that make this annotation.This will retrieve the annotation to which this one is "In Reply To" the actual relationship is specified by the RT entry.This will retrieve the intent of the annotation The values and meanings are specific to the actual annotation See the IT_* constants for the annotation classes.This will retrieve the interior color.This will retrieve the line ending style.float[][]
getPath()
PDF 2.0: This will retrieve the arrays that shall represent the alternating horizontal and vertical coordinates for path building.getPopup()
This will retrieve the popup annotation used for entering/editing the text for this annotation.int
getQ()
This will get the 'quadding' or justification of the text to be displayed.This will get the rectangle difference rectangle.float[]
This will get the margin between the annotations "outer" rectangle defined by /Rect and the boundaries of the underlying caret.This will retrieve the Reply Type (relationship) with the annotation in the IRT entry See the RT_* constants for the available values.This will retrieve the rich text stream which is displayed in the popup window.This will retrieve the line ending style for the start point, possible values shown in the LE_ constants section.This will retrieve the short description of the subject of the annotation.Retrieve the string used as the title of the popup window shown when open and active (by convention this identifies who added the annotation).float[]
This will retrieve the numbers that shall represent the alternating horizontal and vertical coordinates.void
This will set the border effect dictionary, specifying effects to be applied when drawing the line.void
This will set the border style dictionary, specifying the width and dash pattern used in drawing the line.final void
setCallout
(float[] callout) This will set the coordinates of the callout line.void
setConstantOpacity
(float ca) This will set the constant opacity value used when rendering the annotation (excluing any popup).void
setCreationDate
(Calendar creationDate) This will set the date and time the annotation was created.void
setCustomAppearanceHandler
(PDAppearanceHandler appearanceHandler) Set a custom appearance handler for generating the annotations appearance streams.void
setDefaultAppearance
(String daValue) Set the default appearance.void
setDefaultStyleString
(String defaultStyleString) Set the default style string.void
setEndPointEndingStyle
(String style) This will set the line ending style for the end point, see the LE_ constants for the possible values.void
setExternalData
(PDExternalDataDictionary externalData) This will set the external data dictionary.void
setInkList
(float[][] inkList) Sets the paths that make this annotation.void
setInReplyTo
(PDAnnotation irt) This will set the annotation to which this one is "In Reply To" the actual relationship is specified by the RT entry.void
This will set the intent of the annotation The values and meanings are specific to the actual annotation See the IT_* constants for the annotation classes.void
This will set interior color.final void
setLineEndingStyle
(String style) This will set the line ending style.void
setPopup
(PDAnnotationPopup popup) This will set the popup annotation used for entering/editing the text for this annotation.void
setQ
(int q) This will set the quadding/justification of the text.void
This will set the rectangle difference rectangle.void
setRectDifferences
(float difference) This will set the difference between the annotations "outer" rectangle defined by /Rect and boundaries of the underlying.void
setRectDifferences
(float differenceLeft, float differenceTop, float differenceRight, float differenceBottom) This will set the difference between the annotations "outer" rectangle defined by /Rect and the border.void
setReplyType
(String rt) This will set the Reply Type (relationship) with the annotation in the IRT entry See the RT_* constants for the available values.void
This will set the rich text stream which is displayed in the popup window.void
setStartPointEndingStyle
(String style) This will set the line ending style for the start point, see the LE_ constants for the possible values.void
setSubject
(String subj) This will set the short description of the subject of the annotation.void
Set the string used as the title of the popup window shown when open and active (by convention this identifies who added the annotation).void
setVertices
(float[] points) This will set the numbers that shall represent the alternating horizontal and vertical coordinates.Methods inherited from class org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation
createAnnotation, equals, getAnnotationFlags, getAnnotationName, getAppearance, getAppearanceState, getBorder, getColor, getColor, getContents, getCOSObject, getModifiedDate, getNormalAppearanceStream, getOptionalContent, getPage, getRectangle, getStructParent, getSubtype, hashCode, isHidden, isInvisible, isLocked, isLockedContents, isNoRotate, isNoView, isNoZoom, isPrinted, isReadOnly, isToggleNoView, setAnnotationFlags, setAnnotationName, setAppearance, setAppearanceState, setBorder, setColor, setContents, setHidden, setInvisible, setLocked, setLockedContents, setModifiedDate, setModifiedDate, setNoRotate, setNoView, setNoZoom, setOptionalContent, setPage, setPrinted, setReadOnly, setRectangle, setStructParent, setToggleNoView
-
Field Details
-
SUB_TYPE_FREETEXT
Constant for a FreeText type of annotation.- See Also:
-
SUB_TYPE_POLYGON
Constant for an Polygon type of annotation.- See Also:
-
SUB_TYPE_POLYLINE
Constant for an PolyLine type of annotation.- See Also:
-
SUB_TYPE_CARET
Constant for an Caret type of annotation.- See Also:
-
SUB_TYPE_INK
Constant for an Ink type of annotation.- See Also:
-
SUB_TYPE_SOUND
Constant for an Sound type of annotation.- See Also:
-
IT_FREE_TEXT
A plain free-text annotation, also known as a text box comment.- See Also:
-
IT_FREE_TEXT_CALLOUT
A callout, associated with an area on the page through the callout line specified.- See Also:
-
IT_FREE_TEXT_TYPE_WRITER
The annotation is intended to function as a click-to-type or typewriter object.- See Also:
-
RT_REPLY
Constant for an annotation reply type.- See Also:
-
RT_GROUP
Constant for an annotation reply type.- See Also:
-
-
Constructor Details
-
PDAnnotationMarkup
public PDAnnotationMarkup()Constructor. -
PDAnnotationMarkup
Constructor.- Parameters:
dict
- The annotations dictionary.
-
-
Method Details
-
getTitlePopup
Retrieve the string used as the title of the popup window shown when open and active (by convention this identifies who added the annotation).- Returns:
- The title of the popup.
-
setTitlePopup
Set the string used as the title of the popup window shown when open and active (by convention this identifies who added the annotation).- Parameters:
t
- The title of the popup.
-
getPopup
This will retrieve the popup annotation used for entering/editing the text for this annotation.- Returns:
- the popup annotation.
-
setPopup
This will set the popup annotation used for entering/editing the text for this annotation.- Parameters:
popup
- the popup annotation.
-
getConstantOpacity
public float getConstantOpacity()This will retrieve the constant opacity value used when rendering the annotation (excluing any popup).- Returns:
- the constant opacity value.
-
setConstantOpacity
public void setConstantOpacity(float ca) This will set the constant opacity value used when rendering the annotation (excluing any popup).- Parameters:
ca
- the constant opacity value.
-
getRichContents
This will retrieve the rich text stream which is displayed in the popup window.- Returns:
- the rich text stream.
-
setRichContents
This will set the rich text stream which is displayed in the popup window.- Parameters:
rc
- the rich text stream.
-
getCreationDate
This will retrieve the date and time the annotation was created.- Returns:
- the creation date/time.
- Throws:
IOException
- if there is a format problem when converting the date.
-
setCreationDate
This will set the date and time the annotation was created.- Parameters:
creationDate
- the date and time the annotation was created.
-
getInReplyTo
This will retrieve the annotation to which this one is "In Reply To" the actual relationship is specified by the RT entry.- Returns:
- the other annotation or null if there is none.
- Throws:
IOException
- if there is an error creating the other annotation.
-
setInReplyTo
This will set the annotation to which this one is "In Reply To" the actual relationship is specified by the RT entry.- Parameters:
irt
- the annotation this one is "In Reply To".
-
getSubject
This will retrieve the short description of the subject of the annotation.- Returns:
- the subject.
-
setSubject
This will set the short description of the subject of the annotation.- Parameters:
subj
- short description of the subject.
-
getReplyType
This will retrieve the Reply Type (relationship) with the annotation in the IRT entry See the RT_* constants for the available values.- Returns:
- the relationship.
-
setReplyType
This will set the Reply Type (relationship) with the annotation in the IRT entry See the RT_* constants for the available values.- Parameters:
rt
- the reply type.
-
getIntent
This will retrieve the intent of the annotation The values and meanings are specific to the actual annotation See the IT_* constants for the annotation classes.- Returns:
- the intent
-
setIntent
This will set the intent of the annotation The values and meanings are specific to the actual annotation See the IT_* constants for the annotation classes.- Parameters:
it
- the intent
-
getExternalData
This will return the external data dictionary.- Returns:
- the external data dictionary
-
setExternalData
This will set the external data dictionary.- Parameters:
externalData
- the external data dictionary
-
setBorderStyle
This will set the border style dictionary, specifying the width and dash pattern used in drawing the line.- Parameters:
bs
- the border style dictionary to set.
-
getBorderStyle
This will retrieve the border style dictionary, specifying the width and dash pattern used in drawing the line.- Returns:
- the border style dictionary.
-
setLineEndingStyle
This will set the line ending style.- Parameters:
style
- The new style.
-
getLineEndingStyle
This will retrieve the line ending style.- Returns:
- The line ending style, possible values shown in the LE_ constants section, LE_NONE if missing, never null.
-
setInteriorColor
This will set interior color.- Parameters:
ic
- color.
-
getInteriorColor
This will retrieve the interior color.- Returns:
- object representing the color.
-
setBorderEffect
This will set the border effect dictionary, specifying effects to be applied when drawing the line. This is supported by PDF 1.5 and higher.- Parameters:
be
- The border effect dictionary to set.
-
getBorderEffect
This will retrieve the border effect dictionary, specifying effects to be applied used in drawing the line.- Returns:
- The border effect dictionary
-
setInkList
public void setInkList(float[][] inkList) Sets the paths that make this annotation.- Parameters:
inkList
- An array of arrays, each representing a stroked path. Each array shall be a series of alternating horizontal and vertical coordinates. If the parameter is null the entry will be removed.
-
getInkList
public float[][] getInkList()Get one or more disjoint paths that make this annotation.- Returns:
- An array of arrays, each representing a stroked path. Each array shall be a series of alternating horizontal and vertical coordinates.
-
getDefaultAppearance
Get the default appearance.- Returns:
- a string describing the default appearance.
-
setDefaultAppearance
Set the default appearance.- Parameters:
daValue
- a string describing the default appearance.
-
getDefaultStyleString
Get the default style string. The default style string defines the default style for rich text fields.- Returns:
- the DS element of the dictionary object
-
setDefaultStyleString
Set the default style string. Providing null as the value will remove the default style string.- Parameters:
defaultStyleString
- a string describing the default style.
-
getQ
public int getQ()This will get the 'quadding' or justification of the text to be displayed.
0 - Left (default)
1 - Centered
2 - Right
Please see the QUADDING_CONSTANTS inPDVariableText
.- Returns:
- The justification of the text strings.
-
setQ
public void setQ(int q) This will set the quadding/justification of the text. Please see the QUADDING_CONSTANTS inPDVariableText
.- Parameters:
q
- The new text justification.
-
setRectDifference
This will set the rectangle difference rectangle. Giving the difference between the annotations rectangle and where the drawing occurs. (To take account of any effects applied through the BE entry for example)- Parameters:
rd
- the rectangle difference
-
getRectDifference
This will get the rectangle difference rectangle. Giving the difference between the annotations rectangle and where the drawing occurs. (To take account of any effects applied through the BE entry for example)- Returns:
- the rectangle difference
-
setRectDifferences
public void setRectDifferences(float difference) This will set the difference between the annotations "outer" rectangle defined by /Rect and boundaries of the underlying.This will set an equal difference for all sides
- Parameters:
difference
- from the annotations /Rect entry
-
setRectDifferences
public void setRectDifferences(float differenceLeft, float differenceTop, float differenceRight, float differenceBottom) This will set the difference between the annotations "outer" rectangle defined by /Rect and the border.- Parameters:
differenceLeft
- left difference from the annotations /Rect entrydifferenceTop
- top difference from the annotations /Rect entrydifferenceRight
- right difference from the annotations /Rect entrydifferenceBottom
- bottom difference from the annotations /Rect entry
-
getRectDifferences
public float[] getRectDifferences()This will get the margin between the annotations "outer" rectangle defined by /Rect and the boundaries of the underlying caret.- Returns:
- the differences. If the entry hasn't been set am empty array is returned.
-
setCallout
public final void setCallout(float[] callout) This will set the coordinates of the callout line. (PDF 1.6 and higher) Only relevant if the intent is FreeTextCallout.- Parameters:
callout
- An array of four or six numbers specifying a callout line attached to the free text annotation. Six numbers [ x1 y1 x2 y2 x3 y3 ] represent the starting, knee point, and ending coordinates of the line in default user space, four numbers [ x1 y1 x2 y2 ] represent the starting and ending coordinates of the line.
-
getCallout
public float[] getCallout()This will get the coordinates of the callout line. (PDF 1.6 and higher) Only relevant if the intent is FreeTextCallout.- Returns:
- An array of four or six numbers specifying a callout line attached to the free text annotation. Six numbers [ x1 y1 x2 y2 x3 y3 ] represent the starting, knee point, and ending coordinates of the line in default user space, four numbers [ x1 y1 x2 y2 ] represent the starting and ending coordinates of the line.
-
setStartPointEndingStyle
This will set the line ending style for the start point, see the LE_ constants for the possible values.- Parameters:
style
- The new style.
-
getStartPointEndingStyle
This will retrieve the line ending style for the start point, possible values shown in the LE_ constants section.- Returns:
- The ending style for the start point, LE_NONE if missing, never null.
-
setEndPointEndingStyle
This will set the line ending style for the end point, see the LE_ constants for the possible values.- Parameters:
style
- The new style.
-
getEndPointEndingStyle
This will retrieve the line ending style for the end point, possible values shown in the LE_ constants section.- Returns:
- The ending style for the end point, LE_NONE if missing, never null.
-
getVertices
public float[] getVertices()This will retrieve the numbers that shall represent the alternating horizontal and vertical coordinates.- Returns:
- An array of floats representing the alternating horizontal and vertical coordinates.
-
setVertices
public void setVertices(float[] points) This will set the numbers that shall represent the alternating horizontal and vertical coordinates.- Parameters:
points
- an array with the numbers that shall represent the alternating horizontal and vertical coordinates.
-
getPath
public float[][] getPath()PDF 2.0: This will retrieve the arrays that shall represent the alternating horizontal and vertical coordinates for path building.- Returns:
- An array of float arrays, each supplying the operands for a path building operator (m, l or c). The first array should have 2 elements, the others should have 2 or 6 elements.
-
setCustomAppearanceHandler
Set a custom appearance handler for generating the annotations appearance streams.- Parameters:
appearanceHandler
-
-
constructAppearances
public void constructAppearances()Description copied from class:PDAnnotation
Create the appearance entry for this annotation. Not having it may prevent display in some viewers. This method is for overriding in subclasses, the default implementation does nothing.- Overrides:
constructAppearances
in classPDAnnotation
-
constructAppearances
Description copied from class:PDAnnotation
Create the appearance entry for this annotation. Not having it may prevent display in some viewers. This method is for overriding in subclasses, the default implementation does nothing.- Overrides:
constructAppearances
in classPDAnnotation
-