Class Signature
-
- All Implemented Interfaces:
-
android.os.Parcelable
public final class Signature implements Parcelable
Represents a single signature (or signature item). To create an InkAnnotation or StampAnnotation from this signature use the toInkAnnotation and toStampAnnotation methods. You can check the signature annotation type through annotationType.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public class
Signature.Companion
-
Field Summary
Fields Modifier and Type Field Description public final static Long
ID_NOT_SET
public final static Integer
BITMAP_NOT_SET
private final Bitmap
bitmap
private final RectF
boundingBox
private final AnnotationType
annotationType
private final Long
id
private final Integer
inkColor
private final Float
lineWidth
private final List<List<PointF>>
lines
private final BiometricSignatureData
biometricData
private final Float
signatureDrawWidthRatio
private final Integer
bitmapIdentifier
private final RectF
stampRect
public final static Signature.Companion
Companion
-
Method Summary
Modifier and Type Method Description final Bitmap
getBitmap()
Gets the bitmap used for rendering the image signature, or null
if the signature is not an image signature.final RectF
getBoundingBox()
Returns bounding box of the signature data in pdf coordinates. final AnnotationType
getAnnotationType()
The annotation type of the signature, which can either be InkAnnotation or StampAnnotation. final Long
getId()
Signature id number used in signature database. final Integer
getInkColor()
Colour of the ink signature final Float
getLineWidth()
Signature line width in pdf points. final List<List<PointF>>
getLines()
List of ink lines in pdf points. final BiometricSignatureData
getBiometricData()
BiometricSignatureData that was collected with this signature. final Float
getSignatureDrawWidthRatio()
The ratio of signature width to width of the drawing view used when drawing the signature. final Integer
getBitmapIdentifier()
The bitmap identifier used for rendering the image signature, or BITMAP_NOT_SET if the signature is not represented by a bitmap. final RectF
getStampRect()
Bounding rectangle for this signature's bitmap. final JSONObject
toJson()
Converts a signature into a JSON object. final InkAnnotation
toInkAnnotation(PdfDocument document, @IntRange(from = 0) Integer pageIndex, PointF touchPoint)
Builds ink annotation from signature data. final InkAnnotation
toInkAnnotation(PdfDocument document, @IntRange(from = 0) Integer pageIndex, RectF targetRect)
Builds ink annotation from signature data. final InkAnnotation
toInkAnnotation(@IntRange(from = 0) Integer pageIndex)
Builds ink annotation from signature data. final StampAnnotation
toStampAnnotation(PdfDocument document, @IntRange(from = 0) Integer pageIndex, PointF touchPoint)
Builds stamp annotation from signature data. final StampAnnotation
toStampAnnotation(PdfDocument document, @IntRange(from = 0) Integer pageIndex, RectF targetRect)
Builds stamp annotation from signature data. final StampAnnotation
toStampAnnotation(@IntRange(from = 0) Integer pageIndex)
Builds stamp annotation from signature data. -
-
Method Detail
-
getBitmap
@WorkerThread() final Bitmap getBitmap()
Gets the bitmap used for rendering the image signature, or
null
if the signature is not an image signature.NOTE: The returned bitmap is kept in memory in a hash map but this method is meant to be used as an auxiliary method for adding the signature to the document. The bitmap may be destroyed when the app is in background and the system kills the process because needs to release memory resources. This method does not guarantee persistence, to implement this kind of use case it's better to rely on a database, or a cache mechanism that stores the bitmap in the local storage.
- Returns:
Bitmap used for rendering the image signature, or
null
if the signature is not an image signature.
-
getBoundingBox
final RectF getBoundingBox()
Returns bounding box of the signature data in pdf coordinates. The bounding box will always have its
left
andbottom
values equal0
.- Returns:
Rect enclosing all lines of this signature. Always starts at (0,0) (bottom left corner).
-
getAnnotationType
final AnnotationType getAnnotationType()
The annotation type of the signature, which can either be InkAnnotation or StampAnnotation. Useful for getting the correct type through toInkAnnotation and toStampAnnotation.
-
getId
final Long getId()
Signature id number used in signature database. If not set, the default value is ID_NOT_SET.
-
getInkColor
@ColorInt() final Integer getInkColor()
Colour of the ink signature
-
getLineWidth
final Float getLineWidth()
Signature line width in pdf points.
-
getBiometricData
final BiometricSignatureData getBiometricData()
BiometricSignatureData that was collected with this signature. May return
null
if no biometric data was created.
-
getSignatureDrawWidthRatio
final Float getSignatureDrawWidthRatio()
The ratio of signature width to width of the drawing view used when drawing the signature.
This size is used in toAnnotation to auto-size annotation around touched point so that the largest signatures cover 1/4 of the page and smaller less.
-
getBitmapIdentifier
final Integer getBitmapIdentifier()
The bitmap identifier used for rendering the image signature, or BITMAP_NOT_SET if the signature is not represented by a bitmap.
-
getStampRect
final RectF getStampRect()
Bounding rectangle for this signature's bitmap.
-
toJson
final JSONObject toJson()
Converts a signature into a JSON object. You can use that JSON object to recreate the signature later on via fromJson.
- Returns:
A JSON object representing a converted signature.
-
toInkAnnotation
final InkAnnotation toInkAnnotation(PdfDocument document, @IntRange(from = 0) Integer pageIndex, PointF touchPoint)
Builds ink annotation from signature data.
- Parameters:
document
- Target document where the annotation will be added to.pageIndex
- Target page index indocument
where the annotation will be added to.touchPoint
- Point where the annotation should be created.- Returns:
Ink annotation representing this signature, or null if class is not an ink signature.
-
toInkAnnotation
final InkAnnotation toInkAnnotation(PdfDocument document, @IntRange(from = 0) Integer pageIndex, RectF targetRect)
Builds ink annotation from signature data.
- Parameters:
document
- Target document where the annotation will be added to.pageIndex
- Target page index indocument
where the annotation will be added to.targetRect
- Rect on the page into which the annotation should be fitted.- Returns:
Ink annotation representing this signature, or null if class is not an ink signature.
-
toInkAnnotation
final InkAnnotation toInkAnnotation(@IntRange(from = 0) Integer pageIndex)
Builds ink annotation from signature data. This method does not set annotation's bounding box. If you want to create a stamp annotation with bounding box around certain touch point, use .toInkAnnotation instead.
- Parameters:
pageIndex
- Target page index where the annotation will be added to.- Returns:
Ink annotation representing this signature, or null if class is not an ink signature.
-
toStampAnnotation
final StampAnnotation toStampAnnotation(PdfDocument document, @IntRange(from = 0) Integer pageIndex, PointF touchPoint)
Builds stamp annotation from signature data.
- Parameters:
document
- Target document where the annotation will be added to.pageIndex
- Target page index indocument
where the annotation will be added to.touchPoint
- Point where the annotation should be created.- Returns:
Stamp annotation representing this signature, or null if class is not an image signature.
-
toStampAnnotation
final StampAnnotation toStampAnnotation(PdfDocument document, @IntRange(from = 0) Integer pageIndex, RectF targetRect)
Builds stamp annotation from signature data.
- Parameters:
document
- Target document where the annotation will be added to.pageIndex
- Target page index indocument
where the annotation will be added to.targetRect
- Rect on the page into which the annotation should be fitted.- Returns:
Stamp annotation representing this signature, or null if class is not an image signature.
-
toStampAnnotation
final StampAnnotation toStampAnnotation(@IntRange(from = 0) Integer pageIndex)
Builds stamp annotation from signature data. If you want to create a stamp annotation with a specific bounding box around certain touch point, use .toStampAnnotation instead.
- Parameters:
pageIndex
- Target page index where the annotation will be added to.- Returns:
Stamp annotation representing this signature, or null if class is not an image signature.
-
-
-
-