Foxit PDF SDK
fsdk.Signature Class Reference

Public Member Functions

def ClearSignedData ()
 Clear the data and appearance if current signature is singed and verified valid. More...
 
def EnableEmbedFont (enable_embed_font)
 Enable or disable embed font. More...
 
def EnableIncrementalSaveForFirstSigning (enable_incremental_save)
 Enable or disable incremental save for first signing. User should call this function before calling function fsdk.Signature.StartSign .
Default: false. More...
 
def GenerateAppearance ()
 Generate the appearance of unsigned signature. More...
 
def GetAppearanceFlags ()
 Get signature appearance flags. More...
 
def GetBitmap ()
 Get a bitmap which is used for the signature appearance. More...
 
def GetCert (index)
 Get a certificate from current signature's certificate chain by index. More...
 
def GetCertCount ()
 Get the count of certificates in current signature's certificate chain. More...
 
def GetCertificateInfo (key)
 Get certificate information. More...
 
def GetDocPermission ()
 Get document permission for current signature. More...
 
def GetDocument ()
 Get the PDF document, which current signature belongs to. More...
 
def GetFieldMDPAction ()
 Get FieldMDP("MDP" means modification detection and prevention) action type. More...
 
def GetFieldMDPActionFields ()
 Get the field name array which is used for FieldMDP action. More...
 
def GetFilter ()
 Get filter. More...
 
def GetKeyLabel (label_name)
 Get the string for specified key label. More...
 
def GetKeyValue (key)
 Get the string value for specified key name. More...
 
def GetPAdESLevel ()
 Get PAdES level. More...
 
def GetPagingSealGroupElements ()
 Get the group elements of current paging seal signature. More...
 
def GetPagingSealSignature ()
 Get the paging seal signature. More...
 
def GetSignatureDict ()
 Get signature dictionary. More...
 
def GetSignatureType ()
 Get signature type. More...
 
def GetSignedVersionDocument (file_path)
 Get the PDF document in the signed version in which current signature was signed. More...
 
def GetSignTime ()
 Get time of signing. More...
 
def GetState ()
 Get current state. More...
 
def GetSubFilter ()
 Get sub filter. More...
 
def IsEmpty ()
 Check whether current object is empty or not. More...
 
def IsSigned ()
 Check whether current signature is signed or not. More...
 
def IsTimeStamp ()
 Check if current signature is a time stamp signature. More...
 
def SetAppearanceContent (appearance_content)
 Set customized appearance content (as low level drawing operation commands) for signed signature appearance. More...
 
def SetAppearanceFlags (appearance_flags)
 Set signature appearance flags. More...
 
def SetBitmap (bitmap)
 Set a bitmap for the signature appearance. More...
 
def SetCertChain (cert_chain)
 Set a certificate chain. More...
 
def SetCustomObject (key, pdf_object)
 Set custom PDF object for signature dictionary. More...
 
def SetDefaultContentsLength (default_length)
 Set the default length of signature contents which represents signature value (known as signed data). More...
 
def SetDocPermission (permission)
 Set document permission for current signature. More...
 
def SetFilter (filter)
 Set filter. More...
 
def SetImage (image, frame_index)
 Set an image for the signature appearance, with a specified frame index. More...
 
def SetImage (file_path, frame_index)
 Set an image for the signature appearance, with a specified frame index. More...
 
def SetKeyLabel (label_name, label_value)
 Set the string for specified key label. More...
 
def SetKeyValue (key, value)
 Set the string value for specified key name. More...
 
def SetSignTime (sign_time)
 Set time of signing. More...
 
def SetSubFilter (sub_filter)
 Set sub filter. More...
 
def StartSign (cert_path, cert_password, digest_algorithm, save_path, client_data, pause)
 Start signing current signature if current signature is unsigned. More...
 
def StartSign (cert_file_stream, cert_password, digest_algorithm, save_path, client_data, pause)
 Start signing current signature if current signature is unsigned. More...
 
def StartSign (cert_file_stream, cert_password, digest_algorithm, stream_callback, client_data, pause)
 Start signing current signature if current signature is unsigned. More...
 
def StartSign (cert_path, cert_password, digest_algorithm, stream_callback, client_data, pause)
 Start signing current signature if current signature is unsigned. More...
 
def StartVerify (client_data, pause)
 Start verifying the intergrity of current signature if current signature is signed. More...
 

Detailed Description

A digital signature (PDF 1.3) can be used to authenticate the identity of a user and the document's contents. It stores information about the signer and the state of the document when it was signed. The signature is contained in a signature field, as a type of form field, so class Signature is derived from class fsdk.Field . A signature object can be retrieved/added by following functions:

In a signature, filter and sub filter keys are used to specify the filter and sub filter of signature callback object which will be used to sign and verify the signature. Foxit PDF SDK has default signature callbacks for following filter and sub filter:

  • filter: "Adobe.PPKLite" and sub filter: "adbe.pkcs7.detached"

  • filter: "Adobe.PPKLite" and sub filter: "adbe.pkcs7.sha1"

  • filter: "Adobe.PPKLite" and sub filter: "ETSI.CAdES.detached"

  • filter: "Adobe.PPKLite" and sub filter: "ETSI.RFC3161"

For sub filter "ETSI.CAdES.detached" and sub filter "ETSI.RFC3161", please ensure a default time stmap server has been set to TimeStampServerMgr if default signature callbacks for them will be used to do signing. For other filter and sub filter or if user wants to use customized signature callback for above filter and sub filter, user should prepare customized signature callback and register the callback to Foxit PDF SDK by function fsdk.LibraryRegisterSignatureCallback .
This class offers functions to get/set signature information/properties, sign or verify a signature, and so on. For example:

  • To sign an unsigned signature, please use functions fsdk.Signature.StartSign . When signing a signature successfully, user is strongly recommended to close current document and then open the signed PDF document and then do following operation.

  • To verify the integrity of a signed signature, please use functions fsdk.Signature.StartVerify . To check if a signed signature is valid or not, please refer to class LTVVerifier .

  • To retrieve signature dictionary directly, please use function fsdk.Signature.GetSignatureDict .

Before signing an unsigned signature, user can call following functions to set information for signing and signed appearance:

If an unsigned signature has been set some information for signing, but the document is saved directly or closed without signing the signature, these data (including filter and sub filter) will be lost in the saved document or in the closed document. When the document is opened again, the unsigned signature needs to be specified at least filter and sub filter for signing; otherwise, this signature cannot be signed.

See also
fsdk.Field
fsdk.Form
PDFDoc
PDFPage
TimeStampServerMgr
LTVVerifier

Member Function Documentation

◆ ClearSignedData()

def fsdk.Signature.ClearSignedData ( )

Clear the data and appearance if current signature is singed and verified valid.

This function is used for a signed and valid signature.
Attention: From 7.0, this function is only used to verify the intergrity of a signature. To check if a signature is valid or not, please refer to class LTVVerifier .

Returns
true means clear the data and appearance successfully, while false means no need to clear data and appearance or any error.

◆ EnableEmbedFont()

def fsdk.Signature.EnableEmbedFont (   enable_embed_font)

Enable or disable embed font.

Parameters
Aflag indicates that whether to embed font for siganture's text. true means that embed font for siganture's text. false means that not to embed font for siganture's text.
Returns
None.

◆ EnableIncrementalSaveForFirstSigning()

def fsdk.Signature.EnableIncrementalSaveForFirstSigning (   enable_incremental_save)

Enable or disable incremental save for first signing. User should call this function before calling function fsdk.Signature.StartSign .
Default: false.

Parameters
[in]enable_incremental_saveA flag indicates that whether to use incremental save for first signing. true means that use incremental save for first signing. false means that use default save for first signing.
Returns
None.

◆ GenerateAppearance()

def fsdk.Signature.GenerateAppearance ( )

Generate the appearance of unsigned signature.

This function is used to display the unsigned ordinary signature on page without calling the function fsdk.Signature.StartSign .

Returns
true means success, while false means failure.

◆ GetAppearanceFlags()

def fsdk.Signature.GetAppearanceFlags ( )

Get signature appearance flags.

Signature appearance flags indicate which information will be shown. Currently, this is only useful after fsdk.Signature.SetAppearanceFlags is set successfully. For a signature gotten from PDF document, the return value of this function would be useless.

Returns
Signature appearance flags. Please refer to values starting from fsdk.SignatureE_APFlagFoxitFlag and this would be one or a combination of these values.

◆ GetBitmap()

def fsdk.Signature.GetBitmap ( )

Get a bitmap which is used for the signature appearance.

Returns
The bitmap used in appearance. If the return value of function fsdk.Bitmap.IsEmpty for the returned bitmap object is true, that means no bitmap is used in appearance or there is any error.

◆ GetCert()

def fsdk.Signature.GetCert (   index)

Get a certificate from current signature's certificate chain by index.

This function is recommended to be used before verifying a signature. When sub filter of current signature is "adbe.x509.rsa_sha1", application needs to call this function to get verified public certificate before verifying signature. The first certificate in certificate chain is the signing certificate, and it can be used to verify the signature.

Parameters
[in]indexThe index of certificate to be gotten. Valid range: from 0 to (count-1). count is returned by function fsdk.Signature.GetCertCount .
Returns
A certificate.

◆ GetCertCount()

def fsdk.Signature.GetCertCount ( )

Get the count of certificates in current signature's certificate chain.

This function is recommended to be used before verifying a signature. When sub filter of current signature is "adbe.x509.rsa_sha1", application needs to call this function to get the count of certificates in certificate chain and then call function fsdk.Signature.GetCert to get verified public certificate before verifying signature.

Returns
The count of certificates.

◆ GetCertificateInfo()

def fsdk.Signature.GetCertificateInfo (   key)

Get certificate information.

This function is used for a signed signature. Currently, this function only supports for iOS and android platform.

Parameters
[in]keyCertificate key string. Currently it can be one of the following keys:
  • "SerialNumber"

  • "Issuer"

  • "Subject"

  • "ValidPeriodFrom"

  • "ValidPeriodTo"

Returns
Certificate information string.
Note
For "ValidPeriodFrom" or "ValidPeriodTo" key, timezone value will not be computed in.

◆ GetDocPermission()

def fsdk.Signature.GetDocPermission ( )

Get document permission for current signature.

Returns
The document permission.Please refer to values starting from fsdk.SignatureE_DocPermUnrestricted and this should be one of these values.

◆ GetDocument()

def fsdk.Signature.GetDocument ( )

Get the PDF document, which current signature belongs to.

Returns
A PDF document object.

◆ GetFieldMDPAction()

def fsdk.Signature.GetFieldMDPAction ( )

Get FieldMDP("MDP" means modification detection and prevention) action type.

Returns
FieldMDP action type. Please refer to values starting from fsdk.SignatureE_FieldMDPActionNone and this should be one of these values.

◆ GetFieldMDPActionFields()

def fsdk.Signature.GetFieldMDPActionFields ( )

Get the field name array which is used for FieldMDP action.

Returned field name array is associated to the FieldMDP action (which can be checked by function fsdk.Signature.GetFieldMDPAction ):

Returns
FieldMDP action field name array.

◆ GetFilter()

def fsdk.Signature.GetFilter ( )

Get filter.

Filter and sub filter are used to specify which registered signature callback object will be used to sign/verify current signature.

Returns
Filter string.

◆ GetKeyLabel()

def fsdk.Signature.GetKeyLabel (   label_name)

Get the string for specified key label.

If current signature is a time stamp signature, this function will always return an empty string.

Parameters
[in]label_nameKey label. Please refer to values starting from fsdk.SignatureE_LabelNameSigner and this should be one of these values.
Returns
String for specified key label.

◆ GetKeyValue()

def fsdk.Signature.GetKeyValue (   key)

Get the string value for specified key name.

This function is used to get string value of some key in signature dictionary, such as "Reason", "Location" and so on. Specially,

Parameters
[in]keyKey name. Please refer to values starting from fsdk.SignatureE_KeyNameSigner and this should be one of these values.
Returns
The string value.

◆ GetPAdESLevel()

def fsdk.Signature.GetPAdESLevel ( )

Get PAdES level.

Returns
PAdES level. Please refer to values starting from fsdk.SignatureE_PAdESLevelNotPAdES and this would be one of these values.

◆ GetPagingSealGroupElements()

def fsdk.Signature.GetPagingSealGroupElements ( )

Get the group elements of current paging seal signature.

If current signature type is fsdk.SignatureE_SignatureTypePagingSeal , this function will return the array of signature associated with current signature. Otherwise, an empty array will be returned.

Returns
A signature array.

◆ GetPagingSealSignature()

def fsdk.Signature.GetPagingSealSignature ( )

Get the paging seal signature.

If current signature type is fsdk.SignatureE_SignatureTypePagingSeal , this function will return the paging seal signature object associated with current signature.

Returns
A PagingSealSignature object. If the return value of function fsdk.Signature.IsEmpty for the returned object is true, that means current signature is not paging seal signature.

◆ GetSignatureDict()

def fsdk.Signature.GetSignatureDict ( )

Get signature dictionary.

Signature dictionary is a part of signature field dictionary.

Returns
The signature dictionary. If there is any error, this function will return null.

◆ GetSignatureType()

def fsdk.Signature.GetSignatureType ( )

Get signature type.

Returns
Signature type. Please refer to values starting from fsdk.SignatureE_SignatureTypeOrdinary and this would be one of these values.

◆ GetSignedVersionDocument()

def fsdk.Signature.GetSignedVersionDocument (   file_path)

Get the PDF document in the signed version in which current signature was signed.

This function is useful when a PDF document has benn signed by serveral signatures and user wants to get the PDF document in which one signature is signed.

Parameters
[in]file_pathThe full path of the original opened PDF document which current signature belongs to. It should not be an empty string.
Returns
A PDF document object in singed version in which current signature was signed. The returned PDF document may represent a differenct PDF document from current PDF document where current signature is retrieved, or is just current PDF document. User should ensure to keep current PDF document object valid when reading or operating signed version document. Please ensure the returned document object has been loaded successfully, before using most functions in class PDFDoc .

◆ GetSignTime()

def fsdk.Signature.GetSignTime ( )

Get time of signing.

Returns
A date and time object that receives the signing time. If no signing time is found, this function will return a date and time object with all values 0.

◆ GetState()

def fsdk.Signature.GetState ( )

Get current state.

  • Before verifying a signature, this function is to get the state about if current signature is signed or if current signature is lack of data for signing.

  • After verifying a signature, this function is to get the verified state – which indicates that the verified signature is signed; if the verified signature is still unsigned, this function will get the unsigned state instead.

Returns
The value of signature state. Please refer to values starting from fsdk.SignatureE_StateUnknown and this would be one or combination of them.
Specially, if the returned state is fsdk.SignatureE_StateNoSignData , that means current signature has no data for signing, and please at least call function fsdk.Signature.SetKeyValue to set necessary filter and sub filter to current signature. Use can also call following functions to set other data for signing and signed appearance before calling function fsdk.Signature.StartSign :

◆ GetSubFilter()

def fsdk.Signature.GetSubFilter ( )

Get sub filter.

Filter and sub filter are used to specify which registered signature callback object will be used to sign/verify current signature.

Returns
Sub filter string.

◆ IsEmpty()

def fsdk.Signature.IsEmpty ( )

Check whether current object is empty or not.

When the current object is empty, that means current object is useless.

Returns
true means current object is empty, while false means not.

◆ IsSigned()

def fsdk.Signature.IsSigned ( )

Check whether current signature is signed or not.

Returns
true means current signature is signed, and false means not.

◆ IsTimeStamp()

def fsdk.Signature.IsTimeStamp ( )

Check if current signature is a time stamp signature.

Returns
true means current signature is a time stamp signature, while false means not.

◆ SetAppearanceContent()

def fsdk.Signature.SetAppearanceContent (   appearance_content)

Set customized appearance content (as low level drawing operation commands) for signed signature appearance.

This function can only be used for an unsigned signature before calling function fsdk.Signature.StartSign for the unsigned signature.
Once customized appearance content is set, it will be used as the signed appearance. In this case, appearance flags set by fsdk.Signature.SetAppearanceFlags will be ignored and related informations will not be used in appearance – these information are set by: fsdk.Signature.SetSignTime , fsdk.Signature.SetKeyValue (except filter and sub-filter), fsdk.Signature.SetBitmap , fsdk.Signature.SetImage .
If current signature is a time stamp signature, this function will do nothing.

Parameters
[in]appearance_contentCustomized appearance content. This should be sequence of drawing operation commands to be used for the appearance, for example "10 10 m 20 10 l S". Please refer to <PDF Reference 1.7> P196 for more details.
Returns
None.

◆ SetAppearanceFlags()

def fsdk.Signature.SetAppearanceFlags (   appearance_flags)

Set signature appearance flags.

This function is recommended to be used before calling function fsdk.Signature.StartSign for an unsigned signature.
Signature appearance flags indicate which information will be shown in the signed appearance. If customized appearance content has been set by function fsdk.Signature.SetAppearanceContent , appearance flags will be ignored.
If current signature is a time stamp signature, this function will do nothing.

Parameters
[in]appearance_flagsSignature appearance flags. Please refer to values starting from fsdk.SignatureE_APFlagFoxitFlag and this should be one or a combination of these values.
Returns
None.

◆ SetBitmap()

def fsdk.Signature.SetBitmap (   bitmap)

Set a bitmap for the signature appearance.

This function is recommended to be used before calling function fsdk.Signature.StartSign for an unsigned signature. If customized appearance content has been set by function fsdk.Signature.SetAppearanceContent , the bitmap will not be used in signed appearance.
If current signature is a time stamp signature, this function will do nothing.

Parameters
[in]bitmapA bitmap to be set to the appearance. It should be valid.
Returns
None.

◆ SetCertChain()

def fsdk.Signature.SetCertChain (   cert_chain)

Set a certificate chain.

This function is recommended to be used before signing an unsigned signature. When the signature sub filter is "adbe.x509.rsa_sha1", users need to call this function to set the cert chain to the signature. For other sub filter, this function will return directly without doing anything.

Parameters
[in]cert_chainA string array that represents the certificate chain.
Returns
None.

◆ SetCustomObject()

def fsdk.Signature.SetCustomObject (   key,
  pdf_object 
)

Set custom PDF object for signature dictionary.

This function is recommended to be used before calling function fsdk.Signature.StartSign for an unsigned signature.

Parameters
[in]keyThe key of signature dictionary, whose value element will be set. It should not be an empty string.
[in]pdf_objectA custom PDFObject object to be set as the key's value. It should not be null. It can be a direct PDF object or an indirect PDF object.
Returns
None.

◆ SetDefaultContentsLength()

def fsdk.Signature.SetDefaultContentsLength (   default_length)

Set the default length of signature contents which represents signature value (known as signed data).

This function can only be used before function fsdk.Signature.StartSign for an unsigned signature.
Signature contents represent the signature value (known as signed data). When initializing the signature field, the signature contents will be initialized with the default length 7942. When using custom signature callback to sign and verify an unsigned signature, user can call this function to change the default length of signature contents. In this case, user should also ensure that the length of returned signed data in callback function fsdk.SignatureCallback.Sign should not be larger than the default length set by this function.

Parameters
[in]default_lengthThe default length of the signature value (known as signed data), in bytes. It should not be less than 4098.
Returns
None.

◆ SetDocPermission()

def fsdk.Signature.SetDocPermission (   permission)

Set document permission for current signature.

This function is only useful for an unsigned signature. If this function is used for a signed signature, nothing will be done.
Some notes about the permission value:

Parameters
[in]permissionThe document permission. Please refer to values starting from fsdk.SignatureE_DocPermUnrestricted and this should be one of these values.
Returns
None.

◆ SetFilter()

def fsdk.Signature.SetFilter (   filter)

Set filter.

Filter and sub filter are used to specify which registered signature callback object will be used to sign/verify current signature. User could should set filter and sub filter to use default signature callback in Foxit PDF SDK, or use other filter and sub fitler but please ensure that a signature callback object with non-default filter and sub filter should has been registered in Foxit PDF SDK before signing or verifying current signature. Filter and sub filter for default signature callback are:

  • filter: "Adobe.PPKLite" and sub filter: "adbe.pkcs7.detached"

  • filter: "Adobe.PPKLite" and sub filter: "adbe.pkcs7.sha1"

  • filter: "Adobe.PPKLite" and sub filter: "ETSI.CAdES.detached"

  • filter: "Adobe.PPKLite" and sub filter: "ETSI.RFC3161"

Parameters
[in]filterString for filter. It cannot be an empty string.
Returns
None.

◆ SetImage() [1/2]

def fsdk.Signature.SetImage (   image,
  frame_index 
)

Set an image for the signature appearance, with a specified frame index.

This function is recommended to be used before calling function fsdk.Signature.StartSign for an unsigned signature. If customized appearance content has been set by function fsdk.Signature.SetAppearanceContent , the image will not be used in signed appearance.
Input image may contain multiple frames, and only one frame of the image can be set to current signature.
If current signature is a time stamp signature, this function will do nothing.

Parameters
[in]imageAn image. One of its frames will be set to current signature. This image contains at least one frame and the image type should not be fsdk.ImageE_Unknown .
[in]frame_indexFrame index. Valid range: from 0 to (count-1). count is returned by function fsdk.Image.GetFrameCount .
Returns
None.

◆ SetImage() [2/2]

def fsdk.Signature.SetImage (   file_path,
  frame_index 
)

Set an image for the signature appearance, with a specified frame index.

This function is recommended to be used before calling function fsdk.Signature.StartSign for an unsigned signature. If customized appearance content has been set by function fsdk.Signature.SetAppearanceContent , the image will not be used in signed appearance.
Input image may contain multiple frames, and only one frame of the image can be set to current signature.
If current signature is a time stamp signature, this function will do nothing.

Parameters
[in]file_pathA full path of an existing image file. It should not be an empty string.
[in]frame_indexFrame index. Valid range: from 0 to (count-1). count is returned by function fsdk.Image.GetFrameCount of input image file.
Returns
None.

◆ SetKeyLabel()

def fsdk.Signature.SetKeyLabel (   label_name,
  label_value 
)

Set the string for specified key label.

This function is recommended to be used before calling function fsdk.Signature.StartSign for an unsigned signature.
This function is used to set string value for custom label of some key in signature dictionary. If no custom label is set, default labels will be used by Foxit PDF SDK. Please refer to comment of values starting from fsdk.SignatureE_LabelNameSigner for more details.
If current signature is a time stamp signature, this function will do nothing.

Parameters
[in]label_nameKey label. Please refer to values starting from fsdk.SignatureE_LabelNameSigner and this should be one of these values.
[in]label_valueNew string value for key label. If this is an empty string, Foxit PDF SDK will use default label. Please refer to comment of values starting from fsdk.SignatureE_LabelNameSigner for more details.
Returns
None.

◆ SetKeyValue()

def fsdk.Signature.SetKeyValue (   key,
  value 
)

Set the string value for specified key name.

This function is recommended to be used before calling function fsdk.Signature.StartSign for an unsigned signature.
This function is used to set string value of some key in signature dictionary, such as signer, reason, location and so on.
If current signature is a time stamp signature, this function will do nothing.

Parameters
[in]keyKey name. Please refer to values starting from fsdk.SignatureE_KeyNameSigner and this should be one of these values.
[in]valueNew string value.
Returns
None.

◆ SetSignTime()

def fsdk.Signature.SetSignTime (   sign_time)

Set time of signing.

This function is recommended to be used before calling function fsdk.Signature.StartSign for an unsigned signature.

Parameters
[in]sign_timeThe signing time.
Returns
None.

◆ SetSubFilter()

def fsdk.Signature.SetSubFilter (   sub_filter)

Set sub filter.

Filter and sub filter are used to specify which registered signature callback object will be used to sign/verify current signature. User could should set filter and sub filter to use default signature callback in Foxit PDF SDK, or use other filter and sub fitler but please ensure that a signature callback object with non-default filter and sub filter should has been registered in Foxit PDF SDK before signing or verifying current signature. Filter and sub filter for default signature callback are:

  • filter: "Adobe.PPKLite" and sub filter: "adbe.pkcs7.detached"

  • filter: "Adobe.PPKLite" and sub filter: "adbe.pkcs7.sha1"

  • filter: "Adobe.PPKLite" and sub filter: "ETSI.CAdES.detached"

  • filter: "Adobe.PPKLite" and sub filter: "ETSI.RFC3161"

Parameters
[in]sub_filterString for sub filter.
Returns
None.

◆ StartSign() [1/4]

def fsdk.Signature.StartSign (   cert_path,
  cert_password,
  digest_algorithm,
  save_path,
  client_data,
  pause 
)

Start signing current signature if current signature is unsigned.

This function is used for an unsigned signature. Filter and sub filter keys of current signature specify the name of signature callback object which will be used to sign current signature. So before signing, please ensure current signature has valid filter and sub filter string values. If the filter and sub filter are one of following strings that means to use the default signature callback in Foxit PDF SDK:

  • filter: "Adobe.PPKLite" and sub filter: "adbe.pkcs7.detached"

  • filter: "Adobe.PPKLite" and sub filter: "adbe.pkcs7.sha1"

  • filter: "Adobe.PPKLite" and sub filter: "ETSI.CAdES.detached"

  • filter: "Adobe.PPKLite" and sub filter: "ETSI.RFC3161"

For other filter and sub filter or if user wants to use customized signature callback for above filter and sub filter, please ensure a customized signature callback has been registered to Foxit PDF SDK by function fsdk.LibraryRegisterSignatureCallback .
For PDF documents that are compliant with PDF/A specification, fsdk.LibrarySetDefaultICCProfilesPath is recommended to be called and enable embeding font by calling fsdk.Signature.EnableEmbedFont before calling current function. It may take a long time to sign a signature, so Foxit PDF SDK uses a progressive process to do this.

Parameters
[in]cert_pathA full path of a certificate file (including file name and extension), which will be used for signing. This can be an empty string if not necessary in custom signature callback. When this file path is not empty, it should be a valid path.
If default signature callback is to be used for signing current signature, this can be a PFX certificate file.
[in]cert_passwordA password string used to open the cert file. If this is an empty string, that means no password is required.
[in]digest_algorithmThe algorithm of message digest for signed data. Please refer to values starting from fsdk.SignatureE_DigestSHA1 and this should be one of these values.
[in]save_pathA full PDF file path for saving the signing result. The signed document would be saved to another PDF file.
[in]client_dataA user-defined object, which will be passed to call back functions in SignatureCallback . This is useless if the default callback object will be used to sign current signature. Default value: null.
[in]pausePause object which decides if the signing process needs to be paused. This can be null which means not to pause during the signing process. If this is not null, it should be a valid pause object implemented by user. Default value: null.
Returns
A progressive object. Please check the rate of current progress by function fsdk.Progressive.GetRateOfProgress . If the rate is not 100 yet, call function fsdk.Progressive.Continue to continue the progress until the progress is finished.
Note
This function does not support to save signed PDF document directly to the PDF file which is used to construct the related PDF document of current signature. In order to do so, user is recommended to do as following steps:
Assume that the related PDF document object is constructed from a PDF file named "org.pdf".
  1. Use current function to save the signed result to an temporary file. Here, this temporary file is named as "temp.tmp".

  2. Ensure that the related PDF document object has destructed – which is equal to "close document".

  3. Remove "org.pdf" and rename "temp.tmp" to "org.pdf".

Then user can open the signed PDF document to do other operation.

◆ StartSign() [2/4]

def fsdk.Signature.StartSign (   cert_file_stream,
  cert_password,
  digest_algorithm,
  save_path,
  client_data,
  pause 
)

Start signing current signature if current signature is unsigned.

This function is used for an unsigned signature. Filter and sub filter keys of current signature specify the name of signature callback object which will be used to sign current signature. So before signing, please ensure current signature has valid filter and sub filter string values. If the filter and sub filter are one of following strings that means to use the default signature callback in Foxit PDF SDK:

  • filter: "Adobe.PPKLite" and sub filter: "adbe.pkcs7.detached"

  • filter: "Adobe.PPKLite" and sub filter: "adbe.pkcs7.sha1"

  • filter: "Adobe.PPKLite" and sub filter: "ETSI.CAdES.detached"

  • filter: "Adobe.PPKLite" and sub filter: "ETSI.RFC3161"

For other filter and sub filter or if user wants to use customized signature callback for above filter and sub filter, please ensure a customized signature callback has been registered to Foxit PDF SDK by function fsdk.LibraryRegisterSignatureCallback .
For PDF documents that are compliant with PDF/A specification, fsdk.LibrarySetDefaultICCProfilesPath is recommended to be called and enable embeding font by calling fsdk.Signature.EnableEmbedFont before calling current function. It may take a long time to sign a signature, so Foxit PDF SDK uses a progressive process to do this.

Parameters
[in]cert_file_streamA fsdk.StreamCallback object which is implemented by user to access content of a certificate file which will be used for signing. This can be null if not necessary in custom signature callback.
If default signature callback is to be used for signing current signature, a PFX certificate file can be used.
[in]cert_passwordA password string used to open the cert file. If this is an empty string, that means no password is required.
[in]digest_algorithmThe algorithm of message digest for signed data. Please refer to values starting from fsdk.SignatureE_DigestSHA1 and this should be one of these values.
[in]save_pathA full PDF file path for saving the signing result. The signed document would be saved to another PDF file.
[in]client_dataA user-defined object, which will be passed to call back functions in SignatureCallback . This is useless if the default callback object will be used to sign current signature. Default value: null.
[in]pausePause object which decides if the signing process needs to be paused. This can be null which means not to pause during the signing process. If this is not null, it should be a valid pause object implemented by user. Default value: null.
Returns
A progressive object. Please check the rate of current progress by function fsdk.Progressive.GetRateOfProgress . If the rate is not 100 yet, call function fsdk.Progressive.Continue to continue the progress until the progress is finished.
Note
This function does not support to save signed PDF document directly to the PDF file which is used to construct the related PDF document of current signature. In order to do so, user is recommended to do as following steps:
Assume that the related PDF document object is constructed from a PDF file named "org.pdf".
  1. Use current function to save the signed result to an temporary file. Here, this temporary file is named as "temp.tmp".

  2. Ensure that the related PDF document object has destructed – which is equal to "close document".

  3. Remove "org.pdf" and rename "temp.tmp" to "org.pdf".

Then user can open the signed PDF document to do other operation.

◆ StartSign() [3/4]

def fsdk.Signature.StartSign (   cert_file_stream,
  cert_password,
  digest_algorithm,
  stream_callback,
  client_data,
  pause 
)

Start signing current signature if current signature is unsigned.

This function is used for an unsigned signature. Filter and sub filter keys of current signature specify the name of signature callback object which will be used to sign current signature. So before signing, please ensure current signature has valid filter and sub filter string values. If the filter and sub filter are one of following strings that means to use the default signature callback in Foxit PDF SDK:

  • filter: "Adobe.PPKLite" and sub filter: "adbe.pkcs7.detached"

  • filter: "Adobe.PPKLite" and sub filter: "adbe.pkcs7.sha1"

  • filter: "Adobe.PPKLite" and sub filter: "ETSI.CAdES.detached"

  • filter: "Adobe.PPKLite" and sub filter: "ETSI.RFC3161"

For sub filter "ETSI.CAdES.detached" and sub filter "ETSI.RFC3161", please ensure a default time stmap server has been set to TimeStampServerMgr if default signature callbacks for them will be used to do signing. For other filter and sub filter or if user wants to use customized signature callback for above filter and sub filter, please ensure a customized signature callback has been registered to Foxit PDF SDK by function fsdk.LibraryRegisterSignatureCallback .
For PDF documents that are compliant with PDF/A specification, fsdk.LibrarySetDefaultICCProfilesPath is recommended to be called and enable embeding font by calling fsdk.Signature.EnableEmbedFont before calling current function. It may take a long time to sign a signature, so Foxit PDF SDK uses a progressive process to do this.

Parameters
[in]cert_file_streamA fsdk.StreamCallback object which is implemented by user to access content of a certificate file which will be used for signing. This can be null if not necessary in custom signature callback.
If default signature callback is to be used for signing current signature, a PFX certificate file can be used.
[in]cert_passwordA password string used to open the cert file. If this is an empty string, that means no password is required.
[in]digest_algorithmThe algorithm of message digest for signed data. Please refer to values starting from fsdk.SignatureE_DigestSHA1 and this should be one of these values.
[in]stream_callbackA fsdk.StreamCallback object which is implemented by user to save the signing result. The signed document would be saved to another PDF file.
[in]client_dataA user-defined object, which will be passed to call back functions in SignatureCallback . This is useless if the default callback object will be used to sign current signature. Default value: null.
[in]pausePause object which decides if the signing process needs to be paused. This can be null which means not to pause during the signing process. If this is not null, it should be a valid pause object implemented by user. Default value: null.
Returns
A progressive object. Please check the rate of current progress by function fsdk.Progressive.GetRateOfProgress . If the rate is not 100 yet, call function fsdk.Progressive.Continue to continue the progress until the progress is finished.
Note
This function does not support to save signed PDF document directly to the PDF file which is used to construct the related PDF document of current signature. In order to do so, user is recommended to do as following steps:
Assume that the related PDF document object is constructed from a PDF file named "org.pdf".
  1. Use current function to save the signed result to an temporary file. Here, this temporary file is named as "temp.tmp".

  2. Ensure that the related PDF document object has destructed – which is equal to "close document".

  3. Remove "org.pdf" and rename "temp.tmp" to "org.pdf".

Then user can open the signed PDF document to do other operation.

◆ StartSign() [4/4]

def fsdk.Signature.StartSign (   cert_path,
  cert_password,
  digest_algorithm,
  stream_callback,
  client_data,
  pause 
)

Start signing current signature if current signature is unsigned.

This function is used for an unsigned signature. Filter and sub filter keys of current signature specify the name of signature callback object which will be used to sign current signature. So before signing, please ensure current signature has valid filter and sub filter string values. If the filter and sub filter are one of following strings that means to use the default signature callback in Foxit PDF SDK:

  • filter: "Adobe.PPKLite" and sub filter: "adbe.pkcs7.detached"

  • filter: "Adobe.PPKLite" and sub filter: "adbe.pkcs7.sha1"

  • filter: "Adobe.PPKLite" and sub filter: "ETSI.CAdES.detached"

  • filter: "Adobe.PPKLite" and sub filter: "ETSI.RFC3161"

For sub filter "ETSI.CAdES.detached" and sub filter "ETSI.RFC3161", please ensure a default time stmap server has been set to TimeStampServerMgr if default signature callbacks for them will be used to do signing. For other filter and sub filter or if user wants to use customized signature callback for above filter and sub filter, please ensure a customized signature callback has been registered to Foxit PDF SDK by function fsdk.LibraryRegisterSignatureCallback .
For PDF documents that are compliant with PDF/A specification, fsdk.LibrarySetDefaultICCProfilesPath is recommended to be called and enable embeding font by calling fsdk.Signature.EnableEmbedFont before calling current function. It may take a long time to sign a signature, so Foxit PDF SDK uses a progressive process to do this.

Parameters
[in]cert_pathA full path of a certificate file (including file name and extension), which will be used for signing. This can be an empty string if not necessary in custom signature callback. When this file path is not empty, it should be a valid path.
If default signature callback is to be used for signing current signature, this can be a PFX certificate file.
[in]cert_passwordA password string used to open the cert file. If this is an empty string, that means no password is required.
[in]digest_algorithmThe algorithm of message digest for signed data. Please refer to values starting from fsdk.SignatureE_DigestSHA1 and this should be one of these values.
[in]stream_callbackA fsdk.StreamCallback object which is implemented by user to save the signing result. The signed document would be saved to another PDF file.
[in]client_dataA user-defined object, which will be passed to call back functions in SignatureCallback . This is useless if the default callback object will be used to sign current signature. Default value: null.
[in]pausePause object which decides if the signing process needs to be paused. This can be null which means not to pause during the signing process. If this is not null, it should be a valid pause object implemented by user. Default value: null.
Returns
A progressive object. Please check the rate of current progress by function fsdk.Progressive.GetRateOfProgress . If the rate is not 100 yet, call function fsdk.Progressive.Continue to continue the progress until the progress is finished.
Note
This function does not support to save signed PDF document directly to the PDF file which is used to construct the related PDF document of current signature. In order to do so, user is recommended to do as following steps:
Assume that the related PDF document object is constructed from a PDF file named "org.pdf".
  1. Use current function to save the signed result to an temporary file. Here, this temporary file is named as "temp.tmp".

  2. Ensure that the related PDF document object has destructed – which is equal to "close document".

  3. Remove "org.pdf" and rename "temp.tmp" to "org.pdf".

Then user can open the signed PDF document to do other operation.

◆ StartVerify()

def fsdk.Signature.StartVerify (   client_data,
  pause 
)

Start verifying the intergrity of current signature if current signature is signed.

This function is used for a signed signature. Filter and sub filter keys of current signature specify the name of signature callback object which will be used to verify current signature. So before verifying, please ensure: the necessary signature callback object has been registered by function fsdk.LibraryRegisterSignatureCallback . If the filter and sub filter of current signed signature are one of following strings that means to use the default signature callback in Foxit PDF SDK and user does not need to register one for them:

  • filter: "Adobe.PPKLite" and sub filter: "adbe.pkcs7.detached"

  • filter: "Adobe.PPKLite" and sub filter: "adbe.pkcs7.sha1"

  • filter: "Adobe.PPKLite" and sub filter: "ETSI.CAdES.detached"

  • filter: "Adobe.PPKLite" and sub filter: "ETSI.RFC3161"

It may take a long time to verify a signature, so Foxit PDF SDK uses a progressive process to do this.
From 7.0, this function is only used to verify the intergrity of a signature. To check if a signature is valid or not, please refer to class LTVVerifier .

Parameters
[in]client_dataA user-defined object, which will be passed to call back functions in SignatureCallback . This is useless if the default callback object will be used to verify current signature. Default value: null.
[in]pausePause object which decides if the verifying process needs to be paused. This can be null which means not to pause during the verifying process. If this is not null, it should be a valid pause object implemented by user. Default value: null.
Returns
A progressive object. Please check the rate of current progress by function fsdk.Progressive.GetRateOfProgress . If the rate is not 100 yet, call function fsdk.Progressive.Continue to continue the progress until the progress is finished.