Package com.itextpdf.kernel.pdf.annot
Class PdfLineAnnotation
java.lang.Object
com.itextpdf.kernel.pdf.PdfObjectWrapper<PdfDictionary>
com.itextpdf.kernel.pdf.annot.PdfAnnotation
com.itextpdf.kernel.pdf.annot.PdfMarkupAnnotation
com.itextpdf.kernel.pdf.annot.PdfLineAnnotation
The purpose of a line annotation is to display a single straight line on the page. When opened, it displays a pop-up window containing the text of the associated note. See also ISO-320001 12.5.6.7 "Line Annotations".
-
Field Summary
Fields inherited from class com.itextpdf.kernel.pdf.annot.PdfMarkupAnnotation
inReplyTo, popup
Fields inherited from class com.itextpdf.kernel.pdf.annot.PdfAnnotation
Accepted, Canceled, Completed, HIDDEN, HIGHLIGHT_INVERT, HIGHLIGHT_NONE, HIGHLIGHT_OUTLINE, HIGHLIGHT_PUSH, HIGHLIGHT_TOGGLE, INVISIBLE, LOCKED, LOCKED_CONTENTS, Marked, MarkedModel, NO_ROTATE, NO_VIEW, NO_ZOOM, None, page, PRINT, READ_ONLY, Rejected, ReviewModel, STYLE_BEVELED, STYLE_DASHED, STYLE_INSET, STYLE_SOLID, STYLE_UNDERLINE, TOGGLE_NO_VIEW, Unmarked
-
Constructor Summary
ModifierConstructorDescriptionPdfLineAnnotation
(Rectangle rect, float[] line) Creates aPdfLineAnnotation
instance.protected
PdfLineAnnotation
(PdfDictionary pdfObject) Instantiates a newPdfLineAnnotation
instance based onPdfDictionary
instance, that represents existing annotation object in the document. -
Method Summary
Modifier and TypeMethodDescriptionThe dictionaries for some annotation types (such as free text and polygon annotations) can include the BS entry.An array of two numbers that specifies the offset of the caption text from its normal position.A name describing the annotation's caption positioning.boolean
If true, the text specified by thePdfName.Contents
orPdfName.RC
entries (seePdfAnnotation.getContents()
andPdfMarkupAnnotation.getRichText()
) is replicated as a caption in the appearance of the line.The interior color which is used to fill the annotation's line endings.float
A non-negative number that represents the length of leader line extensions that extend from the line proper 180 degrees from the leader lines.float
The length of leader lines in default user space that extend from each endpoint of the line perpendicular to the line itself.float
A non-negative number that represents the length of the leader line offset, which is the amount of empty space between the endpoints of the annotation and the beginning of the leader lines.getLine()
An array of four numbers, [x1 y1 x2 y2], specifying the starting and ending coordinates of the line in default user space.An array of two names specifying the line ending styles that is used in drawing the line.A measure dictionary (see ISO-320001, Table 261) that specifies the scale and units that apply to the line annotation.Gets aPdfName
which value is a subtype of this annotation.setBorderStyle
(PdfDictionary borderStyle) Sets border style dictionary that has more settings than the array specified for the Border entry (PdfAnnotation.getBorder()
).setBorderStyle
(PdfName style) Setter for the annotation's preset border style.setCaptionOffset
(float[] captionOffset) Sets the offset of the caption text from its normal position.setCaptionOffset
(PdfArray captionOffset) Sets the offset of the caption text from its normal position.setCaptionPosition
(PdfName captionPosition) Sets annotation's caption positioning.setContentsAsCaption
(boolean contentsAsCaption) If set to true, the text specified by thePdfName.Contents
orPdfName.RC
entries (seePdfAnnotation.getContents()
andPdfMarkupAnnotation.getRichText()
) will be replicated as a caption in the appearance of the line.setDashPattern
(PdfArray dashPattern) Setter for the annotation's preset dashed border style.setInteriorColor
(float[] interiorColor) An array of numbers in the range 0.0 to 1.0 specifying the interior color which is used to fill the annotation's line endings.setInteriorColor
(PdfArray interiorColor) An array of numbers in the range 0.0 to 1.0 specifying the interior color which is used to fill the annotation's line endings.setLeaderLineExtension
(float leaderLineExtension) Sets the length of leader line extensions that extend from the line proper 180 degrees from the leader lines.setLeaderLineLength
(float leaderLineLength) Sets the length of leader lines in default user space that extend from each endpoint of the line perpendicular to the line itself.setLeaderLineOffset
(float leaderLineOffset) Sets the length of the leader line offset, which is the amount of empty space between the endpoints of the annotation and the beginning of the leader lines.setLineEndingStyles
(PdfArray lineEndingStyles) Sets the line ending styles that are used in drawing the line.setMeasure
(PdfDictionary measure) Sets a measure dictionary that specifies the scale and units that apply to the line annotation.Methods inherited from class com.itextpdf.kernel.pdf.annot.PdfMarkupAnnotation
getCreationDate, getExternalData, getInReplyTo, getInReplyToObject, getIntent, getOpacity, getPopup, getPopupObject, getReplyType, getRichText, getSubject, getText, setCreationDate, setExternalData, setInReplyTo, setIntent, setOpacity, setPopup, setReplyType, setRichText, setSubject, setText
Methods inherited from class com.itextpdf.kernel.pdf.annot.PdfAnnotation
addAssociatedFile, flush, getAppearanceDictionary, getAppearanceObject, getAppearanceState, getAssociatedFiles, getBlendMode, getBorder, getColorObject, getContents, getDate, getDownAppearanceObject, getFlags, getLang, getName, getNonStrokingOpacity, getNormalAppearanceObject, getPage, getPageObject, getRectangle, getRolloverAppearanceObject, getStrokingOpacity, getStructParentIndex, getTitle, hasFlag, isWrappedObjectMustBeIndirect, makeAnnotation, put, remove, resetFlag, setAppearance, setAppearance, setAppearanceState, setBlendMode, setBorder, setBorder, setColor, setColor, setColor, setContents, setContents, setDate, setDownAppearance, setDownAppearance, setFlag, setFlags, setLang, setLayer, setName, setNonStrokingOpacity, setNormalAppearance, setNormalAppearance, setPage, setRectangle, setRolloverAppearance, setRolloverAppearance, setStrokingOpacity, setStructParentIndex, setTitle
Methods inherited from class com.itextpdf.kernel.pdf.PdfObjectWrapper
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
-
Constructor Details
-
PdfLineAnnotation
Creates aPdfLineAnnotation
instance.- Parameters:
-
rect
- the annotation rectangle, defining the location of the annotation on the page in default user space units. SeePdfAnnotation.setRectangle(PdfArray)
. -
line
- an array of four numbers, [x1 y1 x2 y2], specifying the starting and ending coordinates of the line in default user space. See alsogetLine()
.
-
PdfLineAnnotation
Instantiates a newPdfLineAnnotation
instance based onPdfDictionary
instance, that represents existing annotation object in the document.- Parameters:
-
pdfObject
- thePdfDictionary
representing annotation object - See Also:
-
-
Method Details
-
getSubtype
Gets aPdfName
which value is a subtype of this annotation. See ISO-320001 12.5.6, "Annotation Types" for the reference to the possible types.- Specified by:
-
getSubtype
in classPdfAnnotation
- Returns:
- subtype of this annotation.
-
getLine
An array of four numbers, [x1 y1 x2 y2], specifying the starting and ending coordinates of the line in default user space. If thePdfName.LL
entry is present, this value represents the endpoints of the leader lines rather than the endpoints of the line itself.- Returns:
- An array of four numbers specifying the starting and ending coordinates of the line in default user space.
-
getBorderStyle
The dictionaries for some annotation types (such as free text and polygon annotations) can include the BS entry. That entry specifies a border style dictionary that has more settings than the array specified for the Border entry (seePdfAnnotation.getBorder()
). If an annotation dictionary includes the BS entry, then the Border entry is ignored. If annotation includes AP (seePdfAnnotation.getAppearanceDictionary()
) it takes precedence over the BS entry. For more info on BS entry see ISO-320001, Table 166.- Returns:
-
PdfDictionary
which is a border style dictionary or null if it is not specified.
-
setBorderStyle
Sets border style dictionary that has more settings than the array specified for the Border entry (PdfAnnotation.getBorder()
). See ISO-320001, Table 166 andgetBorderStyle()
for more info.- Parameters:
-
borderStyle
- a border style dictionary specifying the line width and dash pattern that shall be used in drawing the annotation’s border. - Returns:
-
this
PdfLineAnnotation
instance.
-
setBorderStyle
Setter for the annotation's preset border style. Possible values arePdfAnnotation.STYLE_SOLID
- A solid rectangle surrounding the annotation.PdfAnnotation.STYLE_DASHED
- A dashed rectangle surrounding the annotation.PdfAnnotation.STYLE_BEVELED
- A simulated embossed rectangle that appears to be raised above the surface of the page.PdfAnnotation.STYLE_INSET
- A simulated engraved rectangle that appears to be recessed below the surface of the page.PdfAnnotation.STYLE_UNDERLINE
- A single line along the bottom of the annotation rectangle.
- Parameters:
-
style
- The new value for the annotation's border style. - Returns:
-
this
PdfLineAnnotation
instance. - See Also:
-
setDashPattern
Setter for the annotation's preset dashed border style. This property has affect only ifPdfAnnotation.STYLE_DASHED
style was used for the annotation border style (seesetBorderStyle(PdfName)
. See ISO-320001 8.4.3.6, "Line Dash Pattern" for the format in which dash pattern shall be specified.- Parameters:
-
dashPattern
- a dash array defining a pattern of dashes and gaps that shall be used in drawing a dashed border. - Returns:
-
this
PdfLineAnnotation
instance.
-
getLineEndingStyles
An array of two names specifying the line ending styles that is used in drawing the line. The first and second elements of the array shall specify the line ending styles for the endpoints defined, respectively, by the first and second pairs of coordinates, (x1, y1) and (x2, y2), in thePdfName.L
array (seegetLine()
. For possible values seesetLineEndingStyles(PdfArray)
.- Returns:
- An array of two names specifying the line ending styles that is used in drawing the line; or null if line endings style is not explicitly defined, default value is [/None /None].
-
setLineEndingStyles
Sets the line ending styles that are used in drawing the line. The first and second elements of the array shall specify the line ending styles for the endpoints defined, respectively, by the first and second pairs of coordinates, (x1, y1) and (x2, y2), in thePdfName.L
array (seegetLine()
. Possible values for styles are:PdfName.Square
- A square filled with the annotation's interior color, if any;PdfName.Circle
- A circle filled with the annotation's interior color, if any;PdfName.Diamond
- A diamond shape filled with the annotation's interior color, if any;PdfName.OpenArrow
- Two short lines meeting in an acute angle to form an open arrowhead;PdfName.ClosedArrow
- Two short lines meeting in an acute angle as in thePdfName.OpenArrow
style and connected by a third line to form a triangular closed arrowhead filled with the annotation's interior color, if any;PdfName.None
- No line ending;PdfName.Butt
- A short line at the endpoint perpendicular to the line itself;PdfName.ROpenArrow
- Two short lines in the reverse direction fromPdfName.OpenArrow
;PdfName.RClosedArrow
- A triangular closed arrowhead in the reverse direction fromPdfName.ClosedArrow
;PdfName.Slash
- A short line at the endpoint approximately 30 degrees clockwise from perpendicular to the line itself;
- Parameters:
-
lineEndingStyles
- An array of two names specifying the line ending styles that is used in drawing the line. - Returns:
-
this
PdfLineAnnotation
instance.
-
getInteriorColor
The interior color which is used to fill the annotation's line endings.- Returns:
-
Color
of eitherDeviceGray
,DeviceRgb
orDeviceCmyk
type which defines interior color of the annotation, or null if interior color is not specified.
-
setInteriorColor
An array of numbers in the range 0.0 to 1.0 specifying the interior color which is used to fill the annotation's line endings.- Parameters:
-
interiorColor
- aPdfArray
of numbers in the range 0.0 to 1.0. The number of array elements determines the colour space in which the colour is defined: 0 - No colour, transparent; 1 - DeviceGray, 3 - DeviceRGB, 4 - DeviceCMYK. For thePdfRedactAnnotation
number of elements shall be equal to 3 (which defines DeviceRGB colour space). - Returns:
-
this
PdfLineAnnotation
instance.
-
setInteriorColor
An array of numbers in the range 0.0 to 1.0 specifying the interior color which is used to fill the annotation's line endings.- Parameters:
-
interiorColor
- an array of floats in the range 0.0 to 1.0. - Returns:
-
this
PdfLineAnnotation
instance.
-
getLeaderLineLength
public float getLeaderLineLength()The length of leader lines in default user space that extend from each endpoint of the line perpendicular to the line itself. A positive value means that the leader lines appear in the direction that is clockwise when traversing the line from its starting point to its ending point (as specified byPdfName.L
(seegetLine()
); a negative value indicates the opposite direction.- Returns:
- a float specifying the length of leader lines in default user space.
-
setLeaderLineLength
Sets the length of leader lines in default user space that extend from each endpoint of the line perpendicular to the line itself. A positive value means that the leader lines appear in the direction that is clockwise when traversing the line from its starting point to its ending point (as specified byPdfName.L
(seegetLine()
); a negative value indicates the opposite direction.- Parameters:
-
leaderLineLength
- a float specifying the length of leader lines in default user space. - Returns:
-
this
PdfLineAnnotation
instance.
-
getLeaderLineExtension
public float getLeaderLineExtension()A non-negative number that represents the length of leader line extensions that extend from the line proper 180 degrees from the leader lines.- Returns:
- a non-negative float that represents the length of leader line extensions; or if the leader line extension is not explicitly set, returns the default value, which is 0.
-
setLeaderLineExtension
Sets the length of leader line extensions that extend from the line proper 180 degrees from the leader lines. This value shall not be set unlessPdfName.LL
is set.- Parameters:
-
leaderLineExtension
- a non-negative float that represents the length of leader line extensions. - Returns:
-
this
PdfLineAnnotation
instance.
-
getLeaderLineOffset
public float getLeaderLineOffset()A non-negative number that represents the length of the leader line offset, which is the amount of empty space between the endpoints of the annotation and the beginning of the leader lines.- Returns:
- a non-negative number that represents the length of the leader line offset, or null if leader line offset is not set.
-
setLeaderLineOffset
Sets the length of the leader line offset, which is the amount of empty space between the endpoints of the annotation and the beginning of the leader lines.- Parameters:
-
leaderLineOffset
- a non-negative number that represents the length of the leader line offset. - Returns:
-
this
PdfLineAnnotation
instance.
-
getContentsAsCaption
public boolean getContentsAsCaption()If true, the text specified by thePdfName.Contents
orPdfName.RC
entries (seePdfAnnotation.getContents()
andPdfMarkupAnnotation.getRichText()
) is replicated as a caption in the appearance of the line.- Returns:
- true, if the annotation text is replicated as a caption, false otherwise. If this property is not set, default value is used which is false.
-
setContentsAsCaption
If set to true, the text specified by thePdfName.Contents
orPdfName.RC
entries (seePdfAnnotation.getContents()
andPdfMarkupAnnotation.getRichText()
) will be replicated as a caption in the appearance of the line.- Parameters:
-
contentsAsCaption
- true, if the annotation text should be replicated as a caption, false otherwise. - Returns:
-
this
PdfLineAnnotation
instance.
-
getCaptionPosition
A name describing the annotation's caption positioning. Valid values arePdfName.Inline
, meaning the caption is centered inside the line, andPdfName.Top
, meaning the caption is on top of the line.- Returns:
-
a name describing the annotation's caption positioning, or null if the caption positioning is not explicitly defined (in this case the default value is used, which is
PdfName.Inline
).
-
setCaptionPosition
Sets annotation's caption positioning. Valid values arePdfName.Inline
, meaning the caption is centered inside the line, andPdfName.Top
, meaning the caption is on top of the line.- Parameters:
-
captionPosition
- a name describing the annotation's caption positioning. - Returns:
-
this
PdfLineAnnotation
instance.
-
getMeasure
A measure dictionary (see ISO-320001, Table 261) that specifies the scale and units that apply to the line annotation.- Returns:
-
a
PdfDictionary
that represents a measure dictionary.
-
setMeasure
Sets a measure dictionary that specifies the scale and units that apply to the line annotation.- Parameters:
-
measure
- aPdfDictionary
that represents a measure dictionary, see ISO-320001, Table 261 for valid contents specification. - Returns:
-
this
PdfLineAnnotation
instance.
-
getCaptionOffset
An array of two numbers that specifies the offset of the caption text from its normal position. The first value is the horizontal offset along the annotation line from its midpoint, with a positive value indicating offset to the right and a negative value indicating offset to the left. The second value is the vertical offset perpendicular to the annotation line, with a positive value indicating a shift up and a negative value indicating a shift down.- Returns:
-
a
PdfArray
of two numbers that specifies the offset of the caption text from its normal position, or null if caption offset is not explicitly specified (in this case a default value is used, which is [0, 0]).
-
setCaptionOffset
Sets the offset of the caption text from its normal position.- Parameters:
-
captionOffset
- aPdfArray
of two numbers that specifies the offset of the caption text from its normal position. The first value defines the horizontal offset along the annotation line from its midpoint, with a positive value indicating offset to the right and a negative value indicating offset to the left. The second value defines the vertical offset perpendicular to the annotation line, with a positive value indicating a shift up and a negative value indicating a shift down. - Returns:
-
this
PdfLineAnnotation
instance.
-
setCaptionOffset
Sets the offset of the caption text from its normal position.- Parameters:
-
captionOffset
- an array of two floats that specifies the offset of the caption text from its normal position. The first value defines the horizontal offset along the annotation line from its midpoint, with a positive value indicating offset to the right and a negative value indicating offset to the left. The second value defines the vertical offset perpendicular to the annotation line, with a positive value indicating a shift up and a negative value indicating a shift down. - Returns:
-
this
PdfLineAnnotation
instance.
-