public class Signature
extends java.lang.Object
Signature
represents as PDF digital signature object.
It's used to authenticate the identity of a user and the document's contents.
It can be constructed by the following ways.
Example:
Signature sig = PDFDocument.getSignature(index); Signature sig = PDFPage.addSignature(rect);
Modifier and Type | Class and Description |
---|---|
static class |
Signature.KeyStoreInfo
Class
KeyStoreInfo represents as keystore information. |
Modifier and Type | Field and Description |
---|---|
static int |
APPEARANCE_DATE
Signature appearance flag constant definition: Flag for show date on description.
|
static int |
APPEARANCE_DN
Signature appearance flag constant definition: Flag for show distinguished name on description.
|
static int |
APPEARANCE_FOXITFLAG
Signature appearance flag constant definition: Flag for show Foxit icon.
|
static int |
APPEARANCE_IMAGE
Signature appearance flag constant definition: Flag for show signature stamp image on its appearance.
|
static int |
APPEARANCE_LABEL
Signature appearance flag constant definition: Flag for show label on description.
|
static int |
APPEARANCE_LOCATION
Signature appearance flag constant definition: Flag for show signing location on description.
|
static int |
APPEARANCE_NAME
Signature appearance flag constant definition: Flag for show signer name on description.
|
static int |
APPEARANCE_REASON
Signature appearance flag constant definition: Flag for show reason on description.
|
static int |
APPEARANCE_TEXT
Signature appearance flag constant definition: Flag for show signature text information on its appearance.
|
static int |
STATE_INVALID
Signature state constant definition: The signature field is signed but has been verified invalid.
|
static int |
STATE_UNKNOWN
Signature state constant definition: The state is unknown.
|
static int |
STATE_UNSIGNED
Signature state constant definition: The state is unsigned.
|
static int |
STATE_VALID
Signature state constant definition: The signature field is signed and has been verified valid.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear the signed data and appearance of current signature.
|
void |
draw(RenderContext context,
Renderer renderer)
Render current signature on a render context.
|
long |
getAnnotFlags()
Get annotation flags of current signature.
|
long |
getAppearanceFlags()
Get the appearance flags of current signature.
|
android.graphics.Bitmap |
getBitmap()
Get the icon bitmap in current signature visual display.
|
java.lang.String |
getContactInfo()
Get contact information of current signature object.
|
DateTime |
getCreationDateTime()
Get creation date and time of current signature.
|
java.lang.String |
getDistinguishedName()
Get distinguished name of the signature owner.
|
PDFDocument |
getDocument()
Retrieve the PDF document object related to current signature.
|
java.lang.String |
getFilter()
Get the name of the preferred signature handler used for current signature.
|
long |
getHandle()
Get the handle of current
Signature object. |
java.lang.String |
getLocation()
Get location information of signature owner.
|
int |
getPageIndex()
Get the index of a PDF page containing current signature.
|
java.lang.String |
getReason()
Get signing reason of current signature.
|
java.lang.String |
getSigner()
Get signer name of current signature.
|
int |
getState()
Get current state of current signature.
|
java.lang.String |
getSubFilter()
Get sub-filter of current signature.
|
java.lang.String |
getText()
Get the text content of current signature appearance.
|
void |
initValue()
Initialize the value of current signature field.
|
boolean |
isSigned()
Determine whether current signature is signed or not.
|
static void |
registerDefaultHandler()
Register a default signature handler to Foxit PDF SDK.
|
static void |
registerHandler(java.lang.String filter,
java.lang.String subFilter,
SignatureHandler handler)
Registers a third-party handler to Foxit PDF SDK, along with its filter and sub-filter.
|
void |
remove()
Remove current signature.
|
void |
resetAppearance()
Reset the appearance of an unsigned signature field.
|
void |
setAnnotFlags(long flags)
Set annotation flags of current signature.
|
void |
setAppearanceFlags(long apFlags)
Set signature appearance flags required for resetting appearance.
|
void |
setBitmap(android.graphics.Bitmap bitmap)
Set a bitmap to icon in current signature display.
|
void |
setContactInfo(java.lang.String contactInfo)
Set contact information of current signature.
|
void |
setCreationDateTime(DateTime tm)
Set the creation date and time of a signature.
|
void |
setDefaultContentsLength(long contentsLen)
Set the default length of current signature value.
|
void |
setDistinguishedName(java.lang.String dn)
Set distinguished name of the signature owner in current signature dictionary.
|
void |
setFilter(java.lang.String filter)
Set the name of filter, which is used to choose a registered signature handler for current signature.
|
void |
setImage(Image img)
Set an
Image object to icon in current signature display. |
void |
setKeyStoreInfo(Signature.KeyStoreInfo ksInfo)
Set the
KeyStoreInfo object to current signature. |
void |
setLocation(java.lang.String location)
Set the CPU host name or physical location of the signature owner.
|
void |
setReason(java.lang.String reason)
Set signing reason of current signature.
|
void |
setSigner(java.lang.String signer)
Set signer name of current signature.
|
void |
setSubFilter(java.lang.String subFilter)
Set the name of sub-filter, which is used to choose a registered signature handler for current signature.
|
void |
setText(java.lang.String text)
Set the text content of current signature appearance.
|
void |
setTSAClient(TSAClient tsa)
Set the
TSAClient object to current signature, for signing PDF file with timestamp. |
Progress |
startSign(FileHandler signedFile)
Sign a PDF document progressively, by using a default signature handler
or a third-party signature handler.
|
Progress |
startVerify()
Verify current signature progressively , by using a default signature handler
or a third-party signature handler.
|
public static final int STATE_UNKNOWN
public static final int STATE_UNSIGNED
public static final int STATE_VALID
public static final int STATE_INVALID
public static final int APPEARANCE_FOXITFLAG
public static final int APPEARANCE_LABEL
public static final int APPEARANCE_REASON
public static final int APPEARANCE_DATE
public static final int APPEARANCE_DN
public static final int APPEARANCE_LOCATION
public static final int APPEARANCE_NAME
public static final int APPEARANCE_IMAGE
public static final int APPEARANCE_TEXT
public long getHandle()
Signature
object.public void setKeyStoreInfo(Signature.KeyStoreInfo ksInfo) throws PDFException
KeyStoreInfo
object to current signature.
Only used for default signature signing.
This function should be called before function
.startSign(FileHandler)
ksInfo
- The specified KeyStoreInfo
object to be set.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setTSAClient(TSAClient tsa)
TSAClient
object to current signature, for signing PDF file with timestamp.
Only used for default signature signing.
This function should be called before function
.
If user wants to sign a PDF file without timestamp, please pass
startSign(FileHandler)
null
to parameter tsa
.
tsa
- The specified TSAClient
object to be set.
null
means no need for timestamp.public static void registerDefaultHandler() throws PDFException
It will used default filter Adobe.PPKLite
and default sub-filter adbe.pkcs7.detached
to register the default signature handler.
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public static void registerHandler(java.lang.String filter, java.lang.String subFilter, SignatureHandler handler) throws PDFException
filter
- The name indicates filter of a third-party handler.
Filter is the name of handler.subFilter
- The name indicates sub-filter of a third-party handler.
Sub-filter is to describe the encoding of signature value
and key information in the signature dictionary.handler
- A third-party handler object to handler the custom signing
and verifying.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
SignatureHandler
public long getAppearanceFlags() throws PDFException
Please refer to the constant definitions
for more
details. The flags can be one or a combination of these constants.APPEARANCE_XXX
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setAppearanceFlags(long apFlags) throws PDFException
apFlags
- Signature appearance flags. Please refer to constant definitions
APPEARANCE_XXX
and
this can be one or combination of these constants.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public android.graphics.Bitmap getBitmap() throws PDFException
Bitmap
object that receives the icon bitmap.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setBitmap(android.graphics.Bitmap bitmap) throws PDFException
bitmap
- A Bitmap
object that specifies the icon of
signature for visual display. This object cannot be released
until function resetAppearance()
has been
called for current signature.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setImage(Image img) throws PDFException
Image
object to icon in current signature display.img
- An Image
object that specifies the icon of
signature for visual display. This object cannot be released
until function resetAppearance()
has
been called for current signature. And then application should
call function Image.release()
to release
this Image
object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
Image
public java.lang.String getContactInfo() throws PDFException
Contact information provides methods about how to contact the signer. It can include mail, telephone etc.
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setContactInfo(java.lang.String contactInfo) throws PDFException
Contact information provides methods about how to contact the signer. It may include mail, telephone etc.
contactInfo
- A String
object that specifies the contact information.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public java.lang.String getDistinguishedName() throws PDFException
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setDistinguishedName(java.lang.String dn) throws PDFException
dn
- The distinguished name of the signature owner.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public DateTime getCreationDateTime() throws PDFException
DateTime
object to receive creation date and time.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
DateTime
public void setCreationDateTime(DateTime tm) throws PDFException
tm
- A DateTime
object that specifies
the creation date and time of the signature.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
DateTime
public void setDefaultContentsLength(long contentsLen) throws PDFException
When initializing the signature field, the length of signature will be
decided by the default setting, then its value would be initialized. The
default size of contents length is 8196. User can call this function to
change the default contents length before calling function
if necessary. But, if this function is
called after function initValue()
, some unexpected
error may occur.initValue()
contentsLen
- The length of the signature value, in bytes. It should be an
even number. If it is less than 8196, then SDK would set the
length to 8196 by default.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public PDFDocument getDocument()
PDFDocument
object.public java.lang.String getFilter() throws PDFException
Filter is the name of signature handler, and it will be used to validate this signature.
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setFilter(java.lang.String filter) throws PDFException
This function is used to set the name of filter, which will be used to choose a registered signature handler,
used for signing or verifying.
If user wants to use default signature handler, please ensure
function registerDefaultHandler()
is called successfully,
and set filter as Adobe.PPKLite
,
with sub-filter set to adbe.pkcs7.detached
.
filter
- The name of the preferred signature handler to use.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public long getAnnotFlags() throws PDFException
A signature field is also a widget annotation. So a signature field can have annotation flags.
Annot.FLAG_XXX
and this can be one or a combination of these constants.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
Annot
public void setAnnotFlags(long flags) throws PDFException
A signature field is also a widget annotation. So a signature field can have annotation flags.
flags
- Annotation flags used to set to signature. Please refer to constant definitions
Annot.FLAG_XXX
and this can
be one or a combination of these constants.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
Annot
public java.lang.String getLocation() throws PDFException
Location information of the signature owner can be the host, MAC address, or a specific physical address. For example "FZ".
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setLocation(java.lang.String location) throws PDFException
Location information of the signature owner can be the host, MAC address, or a specific physical address. For example "FZ".
location
- The signing location.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public int getPageIndex() throws PDFException
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public java.lang.String getReason() throws PDFException
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setReason(java.lang.String reason) throws PDFException
reason
- The signing reason.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public java.lang.String getSigner() throws PDFException
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setSigner(java.lang.String signer) throws PDFException
signer
- The signer name.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public int getState() throws PDFException
STATE_XXX
and this can be one of these constants.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public java.lang.String getSubFilter() throws PDFException
Sub-filter is used to describe the encoding of signature value and key information in the signature dictionary.
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setSubFilter(java.lang.String subFilter) throws PDFException
If user wants to use default signature handler, please ensure
function registerDefaultHandler()
is called successfully,
and set filter as Adobe.PPKLite
,
with sub-filter set to adbe.pkcs7.detached
.
subFilter
- The sub-filter name.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public java.lang.String getText() throws PDFException
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setText(java.lang.String text) throws PDFException
text
- The text content.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean isSigned() throws PDFException
true
means current signature is signed,
while false
means current signature hasn't been signed yet.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public Progress startSign(FileHandler signedFile) throws PDFException
If user wants to do default signature signing, please ensure following functions have been called:
registerDefaultHandler()
, setKeyStoreInfo(KeyStoreInfo)
,
setFilter(String)
, setSubFilter(String)
.
If user wants to do third-party signature signing, please ensure following functions have been called:
registerHandler(String, String, SignatureHandler)
,
setFilter(String)
, setSubFilter(String)
.
Please refer to the comment of these functions for more details.
It may spend a long time to sign a PDF document, so Foxit PDF SDK uses a
progressive process to do this, caller should still call function
to continue signing in steps,
and should call functionProgress.continueProgress(int)
to destroy
this progress object if signing process is over.Progress.release()
signedFile
- The FileHandler
object to save the signed document.Progress
object for progressive signing.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
Progress
,
FileHandler
public Progress startVerify() throws PDFException
If user wants to do default signature verifying, please ensure following functions have been called:
registerDefaultHandler()
,
setFilter(String)
, setSubFilter(String)
.
If user wants to do third-party signature verifying, please ensure following functions have been called:
registerHandler(String, String, SignatureHandler)
,
setFilter(String)
, setSubFilter(String)
.
Please refer to the comment of these functions for more details.
It may spend a long time to verify a signature, so Foxit PDF SDK uses a
progressive process to do this, caller should still call function
to continue verifying in steps
, and should call Progress.continueProgress(int)
to destroy
this progress object if verifying process is over.Progress.release()
Progress
object for progressive verifying.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
Progress
public void clear() throws PDFException
After calling this function successfully, if user wants to set and sign
this signature again, please call function
first.initValue()
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void initValue() throws PDFException
This function should be used for a newly added signature field returned
by function
. When
initializing the signature field, the length of signature will be decided
by the default setting, then its value would be initialized. The default
size of contents length is 8196. User can call function
PDFPage.addSignature(RectF)
to change the
default contents length before calling this function if necessary. But,
if function setDefaultContentsLength(long)
is
called after this function, some unexpected error may occur.setDefaultContentsLength(long)
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFPage
public void remove() throws PDFException
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void resetAppearance() throws PDFException
Usually, this method should be called to generate appearance of a signature object
after the signature object is newly added and its appearance has been set.
If current signature has been signed, PDFException.ERRCODE_UNKNOWNSTATE
will be thrown.
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void draw(RenderContext context, Renderer renderer) throws PDFException
context
- A RenderContext
object.renderer
- A Renderer
object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
RenderContext
,
Renderer