SignDoc SDK (Java)  5.0.0
SignDocDocumentLoader Class Reference

Create SignDocDocument objects. More...

Inheritance diagram for SignDocDocumentLoader:

Public Member Functions

 SignDocDocumentLoader () throws SignDocException
 Constructor. More...
 
synchronized void close ()
 Destroy the underlying native object (for java.lang.AutoCloseable). More...
 
synchronized SignDocDocument loadFromMemory (byte[] aData) throws SignDocException
 Load a document from memory. More...
 
synchronized SignDocDocument loadFromFile (String aPath, boolean aWritable) throws SignDocException
 Load a document from a file. More...
 
synchronized SignDocDocument createPDF (int aMajor, int aMinor) throws SignDocException
 Create an empty PDF document. More...
 
synchronized SignDocDocument createPDFA (int aMajor, int aMinor, String aConformance, byte[] aICC) throws SignDocException
 Create an empty PDF/A document. More...
 
synchronized int ping (java.io.InputStream aStream) throws SignDocException
 Check if a document is supported by this handler. More...
 
synchronized int ping (byte[] aBlob) throws SignDocException
 Check if a document is supported by this handler. More...
 
synchronized void loadFontConfigFile (String aPath) throws SignDocException
 Load font configuration from a file. More...
 
synchronized void loadFontConfigEnvironment (String aName) throws SignDocException
 Load font configuration from files specified by an environment variable. More...
 
synchronized void loadFontConfigStream (java.io.InputStream aStream, String aDirectory) throws SignDocException
 Load font configuration from a stream. More...
 
synchronized void loadFontConfigBlob (byte[] aBlob, String aDirectory) throws SignDocException
 Load font configuration from a blob. More...
 
synchronized void loadPdfFontConfigFile (String aPath) throws SignDocException
 Load font configuration for rendering PDF documents from a file. More...
 
synchronized void loadPdfFontConfigEnvironment (String aName) throws SignDocException
 Load font configuration for rendering PDF documents from files specified by an environment variable. More...
 
synchronized void loadPdfFontConfigStream (java.io.InputStream aStream, String aDirectory) throws SignDocException
 Load font configuration for rendering PDF documents from a stream. More...
 
synchronized void loadPdfFontConfigBlob (byte[] aBlob, String aDirectory) throws SignDocException
 Load font configuration for rendering PDF documents from a blob. More...
 
synchronized String[] getFailedFontFiles () throws SignDocException
 Get the pathnames of font files that failed to load for the most recent loadFontConfig*() or loadPdfFontConfig*() call. More...
 
synchronized void loadTrustedCertificatesFromFile (String aPath) throws SignDocException
 Load trusted root CA certifcates from a file. More...
 
synchronized void loadTrustedCertificatesFromStream (java.io.InputStream aStream) throws SignDocException
 Load trusted root CA certifcates from a stream. More...
 
synchronized void loadTrustedCertificatesFromMemory (byte[] aBlob) throws SignDocException
 Load trusted root CA certifcates from a blob. More...
 
synchronized void setFlags (int aFlags) throws SignDocException
 Set flags modifying the behavior of this SignDocDocumentLoader object and of the SignDocDocument objects created by it. More...
 

Static Public Member Functions

static void setLicenseKey (byte[] aKey, String aProduct, String aVersion, byte[] aToken) throws SignDocException
 Initialize license management with license key. More...
 
static void setLicenseKey (String aKey, String aProduct, String aVersion, byte[] aToken) throws SignDocException, java.io.UnsupportedEncodingException
 Initialize license management with license key. More...
 
static int getRemainingDays (int aWhat) throws SignDocException
 Get the number of days until the license will expire. More...
 
static byte[] generateLicenseToken (String aProduct) throws SignDocException
 Generate a license token for other SDKs also covered by the license key passed to setLicenseKey(). More...
 
static String getVersionNumber () throws SignDocException
 Get the version number of SignDoc SDK. More...
 
static String getComponentVersionNumber (String aComponent) throws SignDocException
 Get the version number of a SignDoc SDK component. More...
 
static int getLicenseTextCount () throws SignDocException
 Get the number of license texts. More...
 
static String getLicenseText (int aIndex) throws SignDocException
 Get a license text. More...
 
static void initLogging (String aLevel, String aPathname, boolean aSetEnv) throws SignDocException
 Initialize logging. More...
 

Static Public Attributes

static final int rd_product = 0
 Specify which expiry date shall be used by getRemainingDays(): Use the expiry date for the product. More...
 
static final int rd_signing = 1
 Specify which expiry date shall be used by getRemainingDays(): Use the expiry date for signing documents. More...
 
static final int f_map_into_memory = 0x01
 Flag for setFlags(): map input file into memory. More...
 

Protected Member Functions

void finalize () throws Throwable
 Finalize this object. More...
 

Detailed Description

Create SignDocDocument objects.

Unless you need differently configured SignDocDocumentLoader objects, you should have only one SignDocDocumentLoader object per process. Loading font configuration files can be expensive, in particular if many fonts have to be scanned.

On Android, this class must be loaded by the UI thread.

Constructor & Destructor Documentation

Constructor.

Member Function Documentation

synchronized void close ( )

Destroy the underlying native object (for java.lang.AutoCloseable).

After calling this method, all methods but close() will throw SignDocUnexpectedErrorException.

synchronized SignDocDocument createPDF ( int  aMajor,
int  aMinor 
) throws SignDocException

Create an empty PDF document.

The PDF document is invalid until you add at least one page. SignDocDocument.addSignature() cannot be used until the document has been saved.

Parameters
[in]aMajorMajor PDF version, must be 1 or 2.
[in]aMinorMinor PDF version, must be 0 through 7 (if aMajor is 1) or 0 (if aMajor is 2).
Returns
A new SignDocDocument object representing the document. After use, SignDocDocument.close() should be to free up native resources as soon as possible.
See also
createPDFA()
synchronized SignDocDocument createPDFA ( int  aMajor,
int  aMinor,
String  aConformance,
byte[]  aICC 
) throws SignDocException

Create an empty PDF/A document.

The PDF document is invalid until you add at least one page. SignDocDocument.addSignature() cannot be used until the document has been saved.

Parameters
[in]aMajorMajor PDF version, must be 1.
[in]aMinorMinor PDF version, must be 0 through 7.
[in]aConformancePDF/A conformance. This string must consist of two characters:
  • A digit (1 through 3) specifying the part of PDF/A the document shall conform to.
  • A letter ('A' or 'B' if the digit is '1', 'A', 'B', or 'U' of the digit is '2' or '3') specifying the PDF/A conformance.
For instance, use "2B" for PDF/A-2b.
[in]aICCThe ICC profile of the PDF/A output intent or null if no output intent shall be added to the document.
Returns
A new SignDocDocument object representing the document. After use, SignDocDocument.close() should be to free up native resources as soon as possible.
See also
createPDF()
void finalize ( ) throws Throwable
protected

Finalize this object.

Do not call this method unless you know what you are doing.

static byte [] generateLicenseToken ( String  aProduct) throws SignDocException
static

Generate a license token for other SDKs also covered by the license key passed to setLicenseKey().

Parameters
[in]aProductThe name of the product which shall be able to use the license key without providing a product version.
Returns
The token.
See also
setLicenseKey()
static String getComponentVersionNumber ( String  aComponent) throws SignDocException
static

Get the version number of a SignDoc SDK component.

Parameters
[in]aComponentThe component. Currently supported are "sppdf", "splm2", and "spooc".
Returns
The version number consisting of 3 or 4 integers separated by dots, .e.g., "1.9.27". null on error.
See also
getVersionNumber()
synchronized String [] getFailedFontFiles ( ) throws SignDocException

Get the pathnames of font files that failed to load for the most recent loadFontConfig*() or loadPdfFontConfig*() call.

This includes files that could not be found and files that could not be loaded. In the former case, the pathname may contain wildcard characters.

Note that loadFontConfig*() and loadPdfFontConfig() no longer fail if a specified font file cannot be found or loaded.

Returns
The pathnames of font files that failed to load.
See also
SignDocDocumentLoader.loadFontConfigBlob(), loadFontConfigEnvironment(), loadFontConfigFile(), loadFontConfigEnvironment(), loadFontConfigStream(), loadPdfFontConfigBlob(), loadPdfFontConfigEnvironment(), loadPdfFontConfigFile(), loadPdfFontConfigEnvironment(), loadPdfFontConfigStream()
static String getLicenseText ( int  aIndex) throws SignDocException
static

Get a license text.

SignDoc SDK includes several Open Source components. You can retrieve the license texts one by one.

Parameters
[in]aIndexThe zero-based index of the license text.
Returns
The license text. Lines are terminated by LF characters. If aIndex is invalid, null will be returned.
See also
getLicenseTextCount()
static int getLicenseTextCount ( ) throws SignDocException
static

Get the number of license texts.

SignDoc SDK includes several Open Source components. You can retrieve the license texts one by one.

Returns
The number of license texts.
See also
getLicenseText()
static int getRemainingDays ( int  aWhat) throws SignDocException
static

Get the number of days until the license will expire.

Parameters
[in]aWhatSelect which expiry date shall be used (rd_product or rd_signing).
Returns
-1 if the license has already expired or is invalid, 0 if the license will expire today, a positive value for the number of days the license is still valid. For licenses without expiry date, that will be several millions of days.
static String getVersionNumber ( ) throws SignDocException
static

Get the version number of SignDoc SDK.

Returns
The version number consisting of 3 integers separated by dots, .e.g., "1.16.7". null on error.
See also
getComponentVersionNumber()
static void initLogging ( String  aLevel,
String  aPathname,
boolean  aSetEnv 
) throws SignDocException
static

Initialize logging.

This function throws an exception if the log file cannot be opened. This function initializes logging for all threads of the current process.

Parameters
[in]aLevelThe logging level: "0" (log nothing) through "5" (log everything), optionally followed by "T" to log process and thread IDs.
[in]aPathnameThe pathname of the log file.
[in]aSetEnvtrue to set the SPDEBUG and SPDEBUGDIR environment variables from aLevel and aPathname, respectively. This will happen only if the log file is opened successfully.
synchronized void loadFontConfigBlob ( byte[]  aBlob,
String  aDirectory 
) throws SignDocException

Load font configuration from a blob.

Suitable fonts are required for putting text containing characters that cannot be encoded using WinAnsiEncoding into text fields, FreeText annotations, DigSig appearances, watermarks, and pages of PDF documents. See section Font Configuration.

The font configuration applies to all SignDocDocument objects created by this object.

Use getFailedFontFiles() after calling this function to get the pathnames of any fonts that could not be loaded.

Parameters
[in]aBlobA blob containing the XML document.
[in]aDirectoryIf non-null, relative font pathnames will be relative to this directory. The directory must exist and must be readable. If null, relative font pathnames will make this function fail.
See also
getFailedFontFiles(), loadFontConfigEnvironment(), SignDocDocumentLoader.loadFontConfigBlob(), loadFontConfigStream()
synchronized void loadFontConfigEnvironment ( String  aName) throws SignDocException

Load font configuration from files specified by an environment variable.

Suitable fonts are required for putting text containing characters that cannot be encoded using WinAnsiEncoding into text fields, FreeText annotations, DigSig appearances, watermarks, and pages of PDF documents. See section Font Configuration.

Under Windows, directories are separated by semicolons. Under Unix, directories are separated by colons.

The font configuration applies to all SignDocDocument objects created by this object.

Use getFailedFontFiles() after calling this function to get the pathnames of any fonts that could not be loaded.

Parameters
[in]aNameThe name of the environment variable.
See also
getFailedFontFiles(), SignDocDocumentLoader.loadFontConfigBlob(), loadFontConfigFile(), loadFontConfigStream()
synchronized void loadFontConfigFile ( String  aPath) throws SignDocException

Load font configuration from a file.

Suitable fonts are required for putting text containing characters that cannot be encoded using WinAnsiEncoding into text fields, FreeText annotations, DigSig appearances, watermarks, and pages of PDF documents. See section Font Configuration.

The font configuration applies to all SignDocDocument objects created by this object.

Use getFailedFontFiles() after calling this function to get the pathnames of any fonts that could not be loaded.

Parameters
[in]aPathThe pathname of the file.
See also
getFailedFontFiles(), SignDocDocumentLoader.loadFontConfigBlob(), loadFontConfigEnvironment(), loadFontConfigStream()
synchronized void loadFontConfigStream ( java.io.InputStream  aStream,
String  aDirectory 
) throws SignDocException

Load font configuration from a stream.

Suitable fonts are required for putting text containing characters that cannot be encoded using WinAnsiEncoding into text fields, FreeText annotations, DigSig appearances, watermarks, and pages of PDF documents. See section Font Configuration.

The font configuration applies to all SignDocDocument objects created by this object.

Use getFailedFontFiles() after calling this function to get the pathnames of any fonts that could not be loaded.

Parameters
[in]aStreamThe font configuration will be read from this stream. This function reads the input completely, it doesn't stop at the end tag.
[in]aDirectoryIf non-null, relative font pathnames will be relative to this directory. The directory must exist and must be readable. If null, relative font pathnames will make this function fail.
See also
getFailedFontFiles(), SignDocDocumentLoader.loadFontConfigBlob(), loadFontConfigEnvironment(), loadFontConfigStream()
synchronized SignDocDocument loadFromFile ( String  aPath,
boolean  aWritable 
) throws SignDocException

Load a document from a file.

Signing the document will overwrite the document, but see string parameter "OutputPath" of SignDocSignatureParameters.

You can open FDF files that reference a PDF file; the referenced PDF file will be opened and the FDF file will be applied to the loaded copy (using sff_font_fail). If the pathname of the referenced PDF file is not an absolute pathname, it will be interpreted as being relative to the directory containing the FDF file.

The file will remain open until the document is saved or the SignDocDocument object is closed or destroyed.

Parameters
[in]aPathPathname of the document file.
[in]aWritableOpen for writing (used for signing TIFF documents in place, ignored for PDF documents).
Returns
A new SignDocDocument object representing the document. After use, SignDocDocument.close() should be to free up native resources as soon as possible.
See also
loadFromMemory(), SignDocDocument.applyFdf(), SignDocSignatureParameters.setInteger()
synchronized SignDocDocument loadFromMemory ( byte[]  aData) throws SignDocException

Load a document from memory.

Parameters
[in]aDataBlob representing the document. The data must not be modified.
Returns
A new SignDocDocument object representing the document. After use, SignDocDocument.close() should be to free up native resources as soon as possible.
See also
loadFromFile()
synchronized void loadPdfFontConfigBlob ( byte[]  aBlob,
String  aDirectory 
) throws SignDocException

Load font configuration for rendering PDF documents from a blob.

Additional fonts may be required for rendering PDF documents. The font configuration for rendering PDF documents contains mappings from font names to font files. See section Font Configuration.

The font configuration for rendering PDF documents is global, ie, it affects all PDF documents, no matter by which SignDocDocumentLoader object they have been created.

Use getFailedFontFiles() after calling this function to get the pathnames of any fonts that could not be loaded.

Parameters
[in]aBlobA blob containing the XML document.
[in]aDirectoryIf non-null, relative font pathnames will be relative to this directory. The directory must exist and must be readable. If null, relative font pathnames will make this function fail.
See also
getFailedFontFiles(), loadPdfFontConfigEnvironment(), loadPdfFontConfigStream()
synchronized void loadPdfFontConfigEnvironment ( String  aName) throws SignDocException

Load font configuration for rendering PDF documents from files specified by an environment variable.

Additional fonts may be required for rendering PDF documents. The font configuration for rendering PDF documents contains mappings from font names to font files. See section Font Configuration.

The font configuration for rendering PDF documents is global, ie, it affects all PDF documents, no matter by which SignDocDocumentLoader object they have been created.

Under Windows, directories are separated by semicolons. Under Unix, directories are separated by colons.

Use getFailedFontFiles() after calling this function to get the pathnames of any fonts that could not be loaded.

Parameters
[in]aNameThe name of the environment variable.
See also
getFailedFontFiles(), loadPdfFontConfigBlob(), loadPdfFontConfigFile(), loadPdfFontConfigStream()
synchronized void loadPdfFontConfigFile ( String  aPath) throws SignDocException

Load font configuration for rendering PDF documents from a file.

Additional fonts may be required for rendering PDF documents. The font configuration for rendering PDF documents contains mappings from font names to font files. See section Font Configuration.

The font configuration for rendering PDF documents is global, ie, it affects all PDF documents, no matter by which SignDocDocumentLoader object they have been created.

Use getFailedFontFiles() after calling this function to get the pathnames of any fonts that could not be loaded.

Parameters
[in]aPathThe pathname of the file.
See also
getFailedFontFiles(), loadPdfFontConfigBlob(), loadPdfFontConfigEnvironment(), loadPdfFontConfigStream()
synchronized void loadPdfFontConfigStream ( java.io.InputStream  aStream,
String  aDirectory 
) throws SignDocException

Load font configuration for rendering PDF documents from a stream.

Additional fonts may be required for rendering PDF documents. The font configuration for rendering PDF documents contains mappings from font names to font files. See section Font Configuration.

The font configuration for rendering PDF documents is global, ie, it affects all PDF documents, no matter by which SignDocDocumentLoader object they have been created.

Use getFailedFontFiles() after calling this function to get the pathnames of any fonts that could not be loaded.

Parameters
[in]aStreamThe font configuration will be read from this stream. This function reads the input completely, it doesn't stop at the end tag.
[in]aDirectoryIf non-null, relative font pathnames will be relative to this directory. The directory must exist and must be readable. If null, relative font pathnames will make this function fail.
See also
getFailedFontFiles(), loadPdfFontConfigBlob()loadPdfFontConfigEnvironment(), loadPdfFontConfigFile()
synchronized void loadTrustedCertificatesFromFile ( String  aPath) throws SignDocException

Load trusted root CA certifcates from a file.

The loaded certificates are used for all SignDocDocument objects created by this object. They are used for signature verification and HTTPS connections. For iOS, they replace the system's trusted anchors, for other operating systems, they are used in addition to the operating system's trusted root CA certificates.

The file must contain either a single DER-encoded X.509 certificate or at least one PEM-encoded X.509 certificate.

Calls to loadTrustedCertificatesFromFile(), loadTrustedCertificatesFromMemory() and loadTrustedCertificatesFromStream() are cumulative.

Parameters
[in]aPathThe pathname of the file.
Returns
true if successful, false on error.
See also
loadTrustedCertificatesFromMemory(), loadTrustedCertificatesFromStream()
synchronized void loadTrustedCertificatesFromMemory ( byte[]  aBlob) throws SignDocException

Load trusted root CA certifcates from a blob.

The loaded certificates are used for all SignDocDocument objects created by this object. They are used for signature verification and HTTPS connections. For iOS, they replace the system's trusted anchors, for other operating systems, they are used in addition to the operating system's trusted root CA certificates.

The blob must contain either a single DER-encoded X.509 certificate or at least one PEM-encoded X.509 certificate.

Parameters
[in]aBlobThe certificates will be read from this blob.
Returns
true if successful, false on error.
See also
loadTrustedCertificatesFromFile(), loadTrustedCertificatesFromStream()
synchronized void loadTrustedCertificatesFromStream ( java.io.InputStream  aStream) throws SignDocException

Load trusted root CA certifcates from a stream.

The loaded certificates are used for all SignDocDocument objects created by this object. They are used for signature verification and HTTPS connections. For iOS, they replace the system's trusted anchors, for other operating systems, they are used in addition to the operating system's trusted root CA certificates.

The stream must contain either a single DER-encoded X.509 certificate or at least one PEM-encoded X.509 certificate.

Parameters
[in]aStreamThe certificates will be read from this stream.
Returns
true if successful, false on error.
See also
loadTrustedCertificatesFromFile(), loadTrustedCertificatesFromMemory()
synchronized int ping ( java.io.InputStream  aStream) throws SignDocException

Check if a document is supported by this handler.

Parameters
[in]aStreamA seekable stream positioned at the first octet of the document.
Returns
The type of the document, SignDocDocument.dt_unknown if the document is not supported.
synchronized int ping ( byte[]  aBlob) throws SignDocException

Check if a document is supported by this handler.

Parameters
[in]aBlobA blob containing the document.
Returns
The type of the document, SignDocDocument.dt_unknown if the document is not supported.
synchronized void setFlags ( int  aFlags) throws SignDocException

Set flags modifying the behavior of this SignDocDocumentLoader object and of the SignDocDocument objects created by it.

Parameters
[in]aFlagsThe flags: 0 or f_map_into_memory.
static void setLicenseKey ( byte[]  aKey,
String  aProduct,
String  aVersion,
byte[]  aToken 
) throws SignDocException
static

Initialize license management with license key.

License management must be initialized before the non-static methods of SignDocDocumentLoader can be used.

Parameters
[in]aKeyThe license key as array of bytes.
[in]aProductShould be null.
[in]aVersionShould be null.
[in]aTokenThe token as array of bytes. Should be null.
See also
generateLicenseToken()
static void setLicenseKey ( String  aKey,
String  aProduct,
String  aVersion,
byte[]  aToken 
) throws SignDocException, java.io.UnsupportedEncodingException
static

Initialize license management with license key.

License management must be initialized before the non-static methods of SignDocDocumentLoader can be used.

Parameters
[in]aKeyThe license key as string.
[in]aProductShould be null.
[in]aVersionShould be null.
[in]aTokenThe token as array of bytes. Should be null.
See also
generateLicenseToken()

Member Data Documentation

final int f_map_into_memory = 0x01
static

Flag for setFlags(): map input file into memory.

If this flag is set, loadFromFile() and other functions will try to map their input file into memory. Doing that may improve performance (on Android, in particular) but read errors and truncating the file will crash the process.

This flag is just a hint and may be ignored.

final int rd_product = 0
static

Specify which expiry date shall be used by getRemainingDays(): Use the expiry date for the product.

See also
getRemainingDays(), rd_signing
final int rd_signing = 1
static

Specify which expiry date shall be used by getRemainingDays(): Use the expiry date for signing documents.

See also
getRemainingDays(), rd_product

The documentation for this class was generated from the following file: