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
public class PDAnnotationMarkup extends PDAnnotation
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.
-
-
Field Summary
Fields Modifier and Type Field Description private PDAppearanceHandler
customAppearanceHandler
static java.lang.String
IT_FREE_TEXT
A plain free-text annotation, also known as a text box comment.static java.lang.String
IT_FREE_TEXT_CALLOUT
A callout, associated with an area on the page through the callout line specified.static java.lang.String
IT_FREE_TEXT_TYPE_WRITER
The annotation is intended to function as a click-to-type or typewriter object.static java.lang.String
RT_GROUP
Constant for an annotation reply type.static java.lang.String
RT_REPLY
Constant for an annotation reply type.static java.lang.String
SUB_TYPE_CARET
Constant for an Caret type of annotation.static java.lang.String
SUB_TYPE_FREETEXT
Constant for a FreeText type of annotation.static java.lang.String
SUB_TYPE_INK
Constant for an Ink type of annotation.static java.lang.String
SUB_TYPE_POLYGON
Constant for an Polygon type of annotation.static java.lang.String
SUB_TYPE_POLYLINE
Constant for an PolyLine type of annotation.static java.lang.String
SUB_TYPE_SOUND
Constant for an Sound type of annotation.
-
Constructor Summary
Constructors Constructor Description PDAnnotationMarkup()
Constructor.PDAnnotationMarkup(COSDictionary dict)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
constructAppearances()
Create the appearance entry for this annotation.void
constructAppearances(PDDocument document)
Create the appearance entry for this annotation.PDBorderEffectDictionary
getBorderEffect()
This will retrieve the border effect dictionary, specifying effects to be applied used in drawing the line.PDBorderStyleDictionary
getBorderStyle()
This will retrieve the border style dictionary, specifying the width and dash pattern used in drawing the line.float[]
getCallout()
This will get the coordinates of the callout line.float
getConstantOpacity()
This will retrieve the constant opacity value used when rendering the annotation (excluing any popup).java.util.Calendar
getCreationDate()
This will retrieve the date and time the annotation was created.java.lang.String
getDefaultAppearance()
Get the default appearance.java.lang.String
getDefaultStyleString()
Get the default style string.java.lang.String
getEndPointEndingStyle()
This will retrieve the line ending style for the end point, possible values shown in the LE_ constants section.PDExternalDataDictionary
getExternalData()
This will return the external data dictionary.float[][]
getInkList()
Get one or more disjoint paths that make this annotation.PDAnnotation
getInReplyTo()
This will retrieve the annotation to which this one is "In Reply To" the actual relationship is specified by the RT entry.java.lang.String
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.PDColor
getInteriorColor()
This will retrieve the interior color.java.lang.String
getLineEndingStyle()
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.PDAnnotationPopup
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.PDRectangle
getRectDifference()
This will get the rectangle difference rectangle.float[]
getRectDifferences()
This will get the margin between the annotations "outer" rectangle defined by /Rect and the boundaries of the underlying caret.java.lang.String
getReplyType()
This will retrieve the Reply Type (relationship) with the annotation in the IRT entry See the RT_* constants for the available values.java.lang.String
getRichContents()
This will retrieve the rich text stream which is displayed in the popup window.java.lang.String
getStartPointEndingStyle()
This will retrieve the line ending style for the start point, possible values shown in the LE_ constants section.java.lang.String
getSubject()
This will retrieve the short description of the subject of the annotation.java.lang.String
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).float[]
getVertices()
This will retrieve the numbers that shall represent the alternating horizontal and vertical coordinates.void
setBorderEffect(PDBorderEffectDictionary be)
This will set the border effect dictionary, specifying effects to be applied when drawing the line.void
setBorderStyle(PDBorderStyleDictionary bs)
This will set the border style dictionary, specifying the width and dash pattern used in drawing the line.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(java.util.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(java.lang.String daValue)
Set the default appearance.void
setDefaultStyleString(java.lang.String defaultStyleString)
Set the default style string.void
setEndPointEndingStyle(java.lang.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
setIntent(java.lang.String it)
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
setInteriorColor(PDColor ic)
This will set interior color.void
setLineEndingStyle(java.lang.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
setRectDifference(PDRectangle rd)
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(java.lang.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
setRichContents(java.lang.String rc)
This will set the rich text stream which is displayed in the popup window.void
setStartPointEndingStyle(java.lang.String style)
This will set the line ending style for the start point, see the LE_ constants for the possible values.void
setSubject(java.lang.String subj)
This will set the short description of the subject of the annotation.void
setTitlePopup(java.lang.String t)
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 Detail
-
customAppearanceHandler
private PDAppearanceHandler customAppearanceHandler
-
SUB_TYPE_FREETEXT
public static final java.lang.String SUB_TYPE_FREETEXT
Constant for a FreeText type of annotation.- See Also:
- Constant Field Values
-
SUB_TYPE_POLYGON
public static final java.lang.String SUB_TYPE_POLYGON
Constant for an Polygon type of annotation.- See Also:
- Constant Field Values
-
SUB_TYPE_POLYLINE
public static final java.lang.String SUB_TYPE_POLYLINE
Constant for an PolyLine type of annotation.- See Also:
- Constant Field Values
-
SUB_TYPE_CARET
public static final java.lang.String SUB_TYPE_CARET
Constant for an Caret type of annotation.- See Also:
- Constant Field Values
-
SUB_TYPE_INK
public static final java.lang.String SUB_TYPE_INK
Constant for an Ink type of annotation.- See Also:
- Constant Field Values
-
SUB_TYPE_SOUND
public static final java.lang.String SUB_TYPE_SOUND
Constant for an Sound type of annotation.- See Also:
- Constant Field Values
-
IT_FREE_TEXT
public static final java.lang.String IT_FREE_TEXT
A plain free-text annotation, also known as a text box comment.- See Also:
- Constant Field Values
-
IT_FREE_TEXT_CALLOUT
public static final java.lang.String IT_FREE_TEXT_CALLOUT
A callout, associated with an area on the page through the callout line specified.- See Also:
- Constant Field Values
-
IT_FREE_TEXT_TYPE_WRITER
public static final java.lang.String IT_FREE_TEXT_TYPE_WRITER
The annotation is intended to function as a click-to-type or typewriter object.- See Also:
- Constant Field Values
-
RT_REPLY
public static final java.lang.String RT_REPLY
Constant for an annotation reply type.- See Also:
- Constant Field Values
-
RT_GROUP
public static final java.lang.String RT_GROUP
Constant for an annotation reply type.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PDAnnotationMarkup
public PDAnnotationMarkup()
Constructor.
-
PDAnnotationMarkup
public PDAnnotationMarkup(COSDictionary dict)
Constructor.- Parameters:
dict
- The annotations dictionary.
-
-
Method Detail
-
getTitlePopup
public java.lang.String 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
public void setTitlePopup(java.lang.String t)
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
public PDAnnotationPopup getPopup()
This will retrieve the popup annotation used for entering/editing the text for this annotation.- Returns:
- the popup annotation.
-
setPopup
public void setPopup(PDAnnotationPopup popup)
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
public java.lang.String getRichContents()
This will retrieve the rich text stream which is displayed in the popup window.- Returns:
- the rich text stream.
-
setRichContents
public void setRichContents(java.lang.String rc)
This will set the rich text stream which is displayed in the popup window.- Parameters:
rc
- the rich text stream.
-
getCreationDate
public java.util.Calendar getCreationDate() throws java.io.IOException
This will retrieve the date and time the annotation was created.- Returns:
- the creation date/time.
- Throws:
java.io.IOException
- if there is a format problem when converting the date.
-
setCreationDate
public void setCreationDate(java.util.Calendar creationDate)
This will set the date and time the annotation was created.- Parameters:
creationDate
- the date and time the annotation was created.
-
getInReplyTo
public PDAnnotation getInReplyTo() throws java.io.IOException
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:
java.io.IOException
- if there is an error creating the other annotation.
-
setInReplyTo
public 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.- Parameters:
irt
- the annotation this one is "In Reply To".
-
getSubject
public java.lang.String getSubject()
This will retrieve the short description of the subject of the annotation.- Returns:
- the subject.
-
setSubject
public void setSubject(java.lang.String subj)
This will set the short description of the subject of the annotation.- Parameters:
subj
- short description of the subject.
-
getReplyType
public java.lang.String 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
public void setReplyType(java.lang.String rt)
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
public java.lang.String 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
public void setIntent(java.lang.String it)
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
public PDExternalDataDictionary getExternalData()
This will return the external data dictionary.- Returns:
- the external data dictionary
-
setExternalData
public void setExternalData(PDExternalDataDictionary externalData)
This will set the external data dictionary.- Parameters:
externalData
- the external data dictionary
-
setBorderStyle
public void setBorderStyle(PDBorderStyleDictionary bs)
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
public PDBorderStyleDictionary 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
public final void setLineEndingStyle(java.lang.String style)
This will set the line ending style.- Parameters:
style
- The new style.
-
getLineEndingStyle
public java.lang.String 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
public void setInteriorColor(PDColor ic)
This will set interior color.- Parameters:
ic
- color.
-
getInteriorColor
public PDColor getInteriorColor()
This will retrieve the interior color.- Returns:
- object representing the color.
-
setBorderEffect
public void setBorderEffect(PDBorderEffectDictionary be)
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
public PDBorderEffectDictionary 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
public java.lang.String getDefaultAppearance()
Get the default appearance.- Returns:
- a string describing the default appearance.
-
setDefaultAppearance
public void setDefaultAppearance(java.lang.String daValue)
Set the default appearance.- Parameters:
daValue
- a string describing the default appearance.
-
getDefaultStyleString
public java.lang.String 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
public void setDefaultStyleString(java.lang.String defaultStyleString)
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
public void setRectDifference(PDRectangle rd)
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
public PDRectangle 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
public void setStartPointEndingStyle(java.lang.String style)
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
public java.lang.String 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
public void setEndPointEndingStyle(java.lang.String style)
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
public java.lang.String 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
public void setCustomAppearanceHandler(PDAppearanceHandler appearanceHandler)
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
public void constructAppearances(PDDocument document)
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
-
-