java.lang.Object | |
↳ | com.pspdfkit.annotations.Annotation |
![]() |
Represents a generic annotation in the PDF document.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
float | DEFAULT_BORDER_WIDTH | Default border width when none is set. | |||||||||
float | DEFAULT_CLOUDY_BORDER_EFFECT_INTENSITY | Default border effect intensity for cloudy borders. | |||||||||
int | OBJECT_NUMBER_NOT_SET | Return value for when the annotation doesn't have a set object number. | |||||||||
int | PAGE_NUMBER_NOT_SET | Return value for when the annotation doesn't have a set page number. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
protected static final Size | DEFAULT_MINIMUM_SIZE | Default minimum size of an annotation in PDF points. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
attachBinaryInstantJsonAttachment(DataProvider dataProvider, String mimeType)
Attaches a binary instant JSON attachment to the annotation.
| ||||||||||
boolean | equals(Object o) | ||||||||||
String |
fetchBinaryInstantJsonAttachment(OutputStream outputStream)
If this annotation has a binary instant JSON attachment, this will write it into the provided
OutputStream . | ||||||||||
void |
generateAppearanceStream()
Regenerates the annotation's appearance stream if necessary.
| ||||||||||
Completable |
generateAppearanceStreamAsync()
Regenerates the annotation's appearance stream if necessary.
| ||||||||||
float |
getAlpha()
Returns the annotation's alpha.
| ||||||||||
AppearanceStreamGenerator |
getAppearanceStreamGenerator()
Returns custom appearance stream generator that overrides appearance stream generation of
this annotation.
| ||||||||||
BlendMode |
getBlendMode()
Returns currently set blend mode.
| ||||||||||
int |
getBorderColor()
Returns the border color of this annotation or
Color#TRANSPARENT if no color is set. | ||||||||||
List<Integer> |
getBorderDashArray()
Returns currently set dash array or
null if no pattern is set. | ||||||||||
BorderEffect |
getBorderEffect()
Returns the current border effect on the annotation or
NO_EFFECT if none
is set. | ||||||||||
float |
getBorderEffectIntensity()
Returns the current border effect intensity.
| ||||||||||
BorderStyle |
getBorderStyle()
Returns the current border style on the annotation or
NONE if none is
set. | ||||||||||
float |
getBorderWidth()
Returns the border line width / thickness.
| ||||||||||
RectF |
getBoundingBox(RectF rect)
Position of this annotation on the page.
| ||||||||||
RectF |
getBoundingBox()
Position of this annotation on the page.
| ||||||||||
int |
getColor()
Returns a color associated with this annotation or
Color#TRANSPARENT if no color is
set. | ||||||||||
String |
getContents()
Returns text contents of the annotation.
| ||||||||||
Annotation |
getCopy(int pageIndex)
Creates a copy of this annotation that isn't attached to the document with the page index set
to given index.
| ||||||||||
Date |
getCreatedDate()
Returns the creation date of the annotation.
| ||||||||||
String |
getCreator()
Returns the name of the creator of this annotation.
| ||||||||||
JSONObject |
getCustomData()
Retrieves custom data for the annotation.
| ||||||||||
int |
getFillColor()
Returns a fill color associated with this object or
Color#TRANSPARENT if no color is
set. | ||||||||||
EnumSet<AnnotationFlags> |
getFlags()
Annotation flags set.
| ||||||||||
Annotation |
getInReplyTo()
Retrieves the annotation this annotation replies to, or
null it this annotation is
not a reply or the license doesn't support replies feature. | ||||||||||
Maybe<Annotation> |
getInReplyToAsync()
Retrieves the annotation this annotation replies to asynchronously.
| ||||||||||
String |
getInstantRecordGroup()
Gets instant record group of the annotation, or
null if this annotation is detached. | ||||||||||
MeasurementInfo |
getMeasurementInfo()
Returns
MeasurementInfo when the annotation is a measurement annotation (see isMeasurement() ,
null if not. | ||||||||||
Size |
getMinimumSize()
Returns the minimum size of the annotation.
| ||||||||||
Date |
getModifiedDate()
Returns the date when this annotation was last modified.
| ||||||||||
String |
getName()
Returns the content of Title/Name field of this annotation.
| ||||||||||
int |
getObjectNumber()
The object number of this annotation inside the PDF document file.
| ||||||||||
int |
getPageIndex()
The page number to which this annotation belongs.
| ||||||||||
String |
getRichText()
Returns rich text contents of the annotation.
| ||||||||||
String |
getSubject()
Returns the subject of this annotation.
| ||||||||||
abstract AnnotationType |
getType()
Gets the annotation type of the annotation.
| ||||||||||
String |
getUuid()
A unique in-memory identifier for each annotation.
| ||||||||||
boolean |
hasBinaryInstantJsonAttachment()
Checks if this annotation has a binary instant JSON attachment.
| ||||||||||
boolean |
hasFlag(AnnotationFlags flag)
Test annotation flag.
| ||||||||||
boolean |
hasLockedContents()
Check if the annotation has locked contents - i.e.
| ||||||||||
int | hashCode() | ||||||||||
boolean |
isAttached()
Tells whether this annotation is attached to a document.
| ||||||||||
boolean |
isLocked()
Check if the annotation is locked - i.e.
| ||||||||||
boolean |
isMeasurement()
Returns
true when the annotation is a measurement annotation. | ||||||||||
boolean |
isModified()
Returns whether the annotation is modified or not.
| ||||||||||
boolean |
isReply()
Whether the annotations is a reply to another annotation.
| ||||||||||
boolean |
isResizable()
Check if the annotation is resizable, or if this is a non-resizable annotation.
| ||||||||||
boolean |
isSignature()
Returns
true when the annotation is a signature annotation. | ||||||||||
void |
renderToBitmap(Bitmap bitmap)
Renders the appearance of this annotation into the passed bitmap.
| ||||||||||
void |
renderToBitmap(Bitmap bitmap, AnnotationRenderConfiguration configuration)
Renders the appearance of this annotation into the passed bitmap.
| ||||||||||
Single<Bitmap> |
renderToBitmapAsync(Bitmap bitmap)
Asynchronously renders the appearance of this annotation into the passed bitmap.
| ||||||||||
Single<Bitmap> |
renderToBitmapAsync(Bitmap bitmap, AnnotationRenderConfiguration configuration)
Asynchronously renders the appearance of this annotation into the passed bitmap.
| ||||||||||
void |
setAlpha(float alpha)
Sets the annotations' alpha value.
| ||||||||||
void |
setAppearanceStreamGenerator(AppearanceStreamGenerator appearanceStreamGenerator)
Sets custom appearance stream generator that overrides appearance stream generation of this
annotation.
| ||||||||||
void |
setBlendMode(BlendMode blendMode)
Sets the blend mode used when generating annotation's appearance stream.
| ||||||||||
void |
setBorderColor(int color)
Sets the border color for this annotation.
| ||||||||||
void |
setBorderDashArray(List<Integer> dashes)
Sets a dash style for the border.
| ||||||||||
void |
setBorderEffect(BorderEffect borderEffect)
Sets a border effect for current annotation.
| ||||||||||
void |
setBorderEffectIntensity(float borderEffectIntensity)
Sets border effect intensity.
| ||||||||||
void |
setBorderStyle(BorderStyle borderStyle)
Sets a border style for current annotation.
| ||||||||||
void |
setBorderWidth(float borderWidth)
Sets border line width / thickness.
| ||||||||||
void |
setBoundingBox(RectF newBoundingBox)
Sets the position and size of this annotation on the page.
| ||||||||||
void |
setColor(int color)
Sets the color for this annotation.
| ||||||||||
void |
setContents(String contents)
Sets text contents of the annotation.
| ||||||||||
void |
setCreatedDate(Date createdDate)
Sets created date for this annotation.
| ||||||||||
void |
setCreator(String creator)
Sets the creator of this annotation.
| ||||||||||
void |
setCustomData(JSONObject customData)
Sets custom data to the annotation.
| ||||||||||
void |
setFillColor(int color)
Sets the fill color for this annotation.
| ||||||||||
void |
setFlags(EnumSet<AnnotationFlags> flags)
Sets annotation flags.
| ||||||||||
void |
setInReplyTo(Annotation annotation)
Sets the annotation that this annotation replies to.
| ||||||||||
void |
setModifiedDate(Date modifiedDate)
Sets last modified date for this annotation.
| ||||||||||
void |
setName(String name)
Sets Title / Name field for this annotation
| ||||||||||
void |
setRichText(String richText)
Sets rich text contents of the annotation.
| ||||||||||
void |
setSubject(String subject)
Sets the subject of this annotation.
| ||||||||||
String |
toInstantJson()
Produces Instant JSON representation of this annotation.
| ||||||||||
String | toString() | ||||||||||
abstract void |
updateTransformationProperties(RectF newBoundingBox, RectF oldBoundingBox)
Annotations may override this method to transform their properties (i.e.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
MeasurementLabelValue |
getMeasurementLabelValue(MeasurementProperties measurementProperties)
Return the measurement label and value for this annotation if it is a measurement.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Default border width when none is set.
Default border effect intensity for cloudy borders.
Return value for when the annotation doesn't have a set object number.
Return value for when the annotation doesn't have a set page number.
Default minimum size of an annotation in PDF points.
Attaches a binary instant JSON attachment to the annotation. Can later be fetched using
fetchBinaryInstantJsonAttachment(OutputStream)
.
dataProvider | The DataProvider containing the binary instant JSON data to
attach. |
---|---|
mimeType | The mime type of the data that will be attached. |
IllegalStateException | If there is a error while attaching the the binary JSON attachment. |
---|
If this annotation has a binary instant JSON attachment, this will write it into the provided
OutputStream
.
outputStream | The OutputStream to write the binary instant JSON into. |
---|
IllegalStateException | If there is a error while fetching the attachment. |
---|
Regenerates the annotation's appearance stream if necessary.
Note: this call may block for a while and should not be invoked on the main thread.
Regenerates the annotation's appearance stream if necessary.
Returns the annotation's alpha.
<0.0f...1.0f>
. Default
value is 1.0f.
Returns custom appearance stream generator that overrides appearance stream generation of this annotation.
null
when no custom
appearance stream generator is set.
Returns currently set blend mode. Defaults to NORMAL
for all annotations
except highlight.
Returns the border color of this annotation or Color#TRANSPARENT
if no color is set.
Note that alpha channel is not taken into account as per PDF specifications.
Color#TRANSPARENT
if no color is set.
Returns currently set dash array or null
if no pattern is set.
Returns the current border effect intensity.
Returns the border line width / thickness.
Position of this annotation on the page. Changing bounding box does not change annotations
bounds. Instead call setBoundingBox(RectF)
to change annotation bounds.
rect | Reuse rectangle. |
---|
Position of this annotation on the page. The returned RectF
is a copy, so changing
its values won't update the annotation's bounds. Instead call setBoundingBox(RectF)
providing the altered rect to update the annotation.
Returns a color associated with this annotation or Color#TRANSPARENT
if no color is
set. Note that alpha channel is not taken into account as per PDF specifications. This is the
text color for FreeTextAnnotation
and WidgetAnnotation
.
Color#TRANSPARENT
if none is set.
Returns text contents of the annotation. This is usually the displayed text for annotations that display text or accessibility label for annotations that don't.
null
if it's not set.
Creates a copy of this annotation that isn't attached to the document with the page index set
to given index. If this type of annotation can't be copied this method will return null
.
Note: This will reset the name
of the resulting annotation to an
automatically generated UUID if you want to keep the original name you have to manually set
it on the returned copy.
pageIndex | The page index the copied annotation should belong to. |
---|
null
if no copy could be made.
Returns the creation date of the annotation.
null
if non-existent.
Returns the name of the creator of this annotation.
null
if not set.
Retrieves custom data for the annotation.
Annotations can store additional user-specified data. PSPDFKit will not use or evaluate
customData
in the UI directly. You have full control over this property. For new
annotation, this defaults to null
.
null
if annotation has no custom data.
Returns a fill color associated with this object or Color#TRANSPARENT
if no color is
set. Note that alpha channel is not taken into account as per PDF specifications.
Color#TRANSPARENT
if no color is set.
Annotation flags set. Changing returned EnumSet
does not change annotation flags.
Instead call setFlags(EnumSet)
to change annotation flags.
Retrieves the annotation this annotation replies to, or null
it this annotation is
not a reply or the license doesn't support replies feature.
Note: this call may block for a while and should not be invoked on the main thread.
Annotation
this annotation replies to, or null
.Retrieves the annotation this annotation replies to asynchronously. The response is emitted inside the RxJava's Maybe. It will contain the requested annotation if it exists, or be empty otherwise.
Gets instant record group of the annotation, or null
if this annotation is detached.
Returns MeasurementInfo
when the annotation is a measurement annotation (see isMeasurement()
,
null
if not.
Throws an InvalidPSPDFKitLicenseException
if measurement tools component is not licensed.
Throws an IllegalStateException
if there is an issue generating the information.
MeasurementInfo
Of the measurement annotation
OR
null
if it's not a measurement.
Returns the minimum size of the annotation.
Returns the date when this annotation was last modified.
null
if non-existent.
Returns the content of Title/Name field of this annotation. This can be used to globally identify the annotation. This property will be automatically set to a type 4 (pseudo random) UUID during annotation construction time.
null
. By default, this is initialized to a random
UUID.
The object number of this annotation inside the PDF document file. This method will only
return a valid object number if this annotation is attached to a document (i.e. when isAttached()
returns true
). If the annotation is not attached to any document, this
method will return OBJECT_NUMBER_NOT_SET
.
Note that there is no guarantee that object numbers stay the same when saving and
reopening a document. If a persistent identifier is required, use the getName()
property instead, which by default is initialized to hold a type 4 (pseudo randomly
generated) UUID.
OBJECT_NUMBER_NOT_SET
if the
annotation is not attached to a document.
The page number to which this annotation belongs. If the annotation is not attached to any
document, this method will return PAGE_NUMBER_NOT_SET
.
PAGE_NUMBER_NOT_SET
if not
set.
Returns rich text contents of the annotation. This is text to be displayed in a pop-up for text markup annotations.
null
if it's not set.
Returns the subject of this annotation.
null
if it's not set.
Gets the annotation type of the annotation.
A unique in-memory identifier for each annotation. Generated at runtime, therefore not persisted (in the PDF).
Unlike getName()
, this method is guaranteed to always return a non-null value,
even for existing annotations in a document.
Checks if this annotation has a binary instant JSON attachment. For example, a stamp annotation with an image has one.
true
if this annotation has a binary instant JSON attachment, false
otherwise.IllegalStateException | If there is a error while checking for attachments. |
---|
Test annotation flag.
true
if flag is set on this annotation, false
otherwise.
Check if the annotation has locked contents - i.e. annotation content can't be modified.
true
if the annotation has locked content or false
if annotation's
content can be modified.
Tells whether this annotation is attached to a document.
true
if this annotation is attached to a document, or false
if it is
not attached.
Check if the annotation is locked - i.e. annotation can't be deleted or modified (except contents).
true
if the annotation is locked or false
if it can be freely
modified.
Returns true
when the annotation is a measurement annotation.
Measurement annotations can be:
- LineAnnotation
: Distance measurement
- PolylineAnnotation
: Perimeter measurement
- PolygonAnnotation
: Polygonal area measurement
- CircleAnnotation
: Elliptical area measurement
- SquareAnnotation
: Rectangular area measurement
true
when the annotation is a measurement annotation.
Returns whether the annotation is modified or not.
true
if this annotations has been modified and the document
containing it hasn't been saved as part of the document.
Whether the annotations is a reply to another annotation.
true
if this annotations is a reply to another annotation, false
otherwise.
Check if the annotation is resizable, or if this is a non-resizable annotation.
true
if the annotation can be resized (e.g. ink annotation) or false
if it is a non-resizable one (e.g. note annotation).
Returns true
when the annotation is a signature annotation.
Annotations that can be signatures are InkAnnotation
and StampAnnotation
.
true
when the annotation is a signature annotation.
Renders the appearance of this annotation into the passed bitmap.
bitmap | Target bitmap to render the annotation into. |
---|
Renders the appearance of this annotation into the passed bitmap.
bitmap | Target bitmap to render the annotation into. |
---|---|
configuration | Advanced annotation rendering configuration. |
Asynchronously renders the appearance of this annotation into the passed bitmap.
bitmap | Target bitmap to render the annotation into. |
---|
Asynchronously renders the appearance of this annotation into the passed bitmap.
bitmap | Target bitmap to render the annotation into. |
---|---|
configuration | Advanced annotation rendering configuration. |
Sets the annotations' alpha value. It's the value in range <0.0f...1.0f>
.
Sets custom appearance stream generator that overrides appearance stream generation of this
annotation. The appearanceStreamGenerator
will be called when necessary to generate
annotation's appearance stream.
Note: This does not automatically remove existing appearance streams. The
appearance stream only gets generated when the annotation has been modified or when calling
generateAppearanceStream()
explicitly.
appearanceStreamGenerator | Appearance stream generator for this annotation or null to remove custom appearance stream generator from this
annotation.
|
---|
Sets the blend mode used when generating annotation's appearance stream.
blendMode | blend mode to use when generating annotations appearance stream. |
---|
Sets the border color for this annotation. Border color usually redirects to color, unless
overridden to have a real backing store (this is the case for WidgetAnnotation
).
Note: The annotation will only store the RGB part and discard the alpha channel
set here. Annotation opacity is set via the setAlpha(float)
property.
color | The border color or Color#TRANSPARENT to clear the field.
|
---|
Sets a dash style for the border. It's in form of an array where the numbers mean full_length, empty length, full_length... etc.
. The pattern is repeated.
To get a dashed border, setBorderStyle(BorderStyle)
should be set to DASHED
and color of the border should be set with setBorderColor(int)
.
dashes | List of integer numbers representing lengths of a pattern. E.g. { 2, 3 } will generate a dash pattern with lines of length 2 and empty spaces of length 3. |
---|
Sets a border effect for current annotation. Currently supports no effect and cloudy.
Note: setBorderEffectIntensity(float)
should be set to non-zero (e.g.
1.0) for Cloudy border to be displayed.
borderEffect | BorderEffect to be set. NO_EFFECT to clear
it.
|
---|
Sets border effect intensity. Valid only if the border effect is CLOUDY
.
The value is suggested to be between 0 and 2 but other values are valid as well. Default
value is 0.
borderEffectIntensity | Intensity of the border effect. |
---|
Sets a border style for current annotation. It should be accompanied with setBorderColor(int)
call to set the border color as well.
borderStyle | BorderStyle to be set. NONE to clear it.
|
---|
Sets border line width / thickness. For border to appear, color and style should be set via
setBorderColor(int)
and setBorderStyle(BorderStyle)
as well.
borderWidth | border width in PDF points |
---|
Sets the position and size of this annotation on the page.
newBoundingBox | Annotation's position on the page in PDF coordinates. |
---|
Sets the color for this annotation. This is the text color for FreeTextAnnotation
,
WidgetAnnotation
, and RedactionAnnotation
.
Note: The annotation will only store the RGB part and discard the alpha channel
set here. Annotation opacity is set via the setAlpha(float)
property.
color | The annotation color or Color#TRANSPARENT to clear the field.
|
---|
Sets text contents of the annotation. This is usually the displayed text for annotations that display text or accessibility label for annotations that don't.
contents | Contents string or null to clear the field.
|
---|
Sets created date for this annotation.
createdDate | Created date in UTC time or null to clear the field.
|
---|
Sets the creator of this annotation.
creator | Creator or null to clear the field.
|
---|
Sets custom data to the annotation. The contents of this property are saved to the document when saving.
Annotations can store additional user-specified data here. PSPDFKit will not use or
evaluate customData
in the UI directly. You have full control over this property. For
new annotation, this defaults to null
.
customData | JSONObject to set as the custom data. null to clear the custom data
property.
|
---|
Sets the fill color for this annotation. Only used for certain annotation types. LinkAnnotation
s, for example, aren't affected by this property.
Note: The annotation will only store the RGB part and discard the alpha channel
set here. Annotation opacity is set via the setAlpha(float)
property.
color | The annotation color or Color#TRANSPARENT to clear the field.
|
---|
Sets annotation flags.
flags | Set of annotation flags to be set. |
---|
Sets the annotation that this annotation replies to.
annotation | Annotation to which this annotation is a reply. |
---|
Sets last modified date for this annotation.
modifiedDate | Last modified date in UTC time or null to clear the field.
|
---|
Sets Title / Name field for this annotation
name | Name of this annotation or null to clear the field.
|
---|
Sets rich text contents of the annotation. This is the text to be displayed in a pop-up for text markup annotations.
richText | Rich text contents for annotation or null to clear the field.
|
---|
Sets the subject of this annotation.
Starting with PSPDFKit 5.0 this method will no longer affect the appearance of stamp
annotations. Use setStampType(StampType)
and setTitle(String)
instead.
subject | The subject of this annotation or null to clear the field.
|
---|
Produces Instant JSON representation of this annotation.
Note: Make sure the annotation is attached to the document before exporting it to Instant JSON.
Annotations may override this method to transform their properties (i.e. points, rects, sizes) whenever the bounding box of the annotation changed.
newBoundingBox | New bounding box of the annotation (in PDF points). |
---|---|
oldBoundingBox | Old bounding box of the annotation (in PDF points). |
Return the measurement label and value for this annotation if it is a measurement. Returns null if it's not a measurement. Overridden in child shape annotations who can be measurements. Calculates the measurement value based on the passed `measurementProperties` and shape size.
measurementProperties | the properties for this measurement. Including Scale and FloatPrecision . |
---|