Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Package Functions

de.softpro.doc.SignDocDocumentLoader Class Reference

Create SignDocDocument objects. More...

List of all members.

Public Member Functions

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

Static Public Member Functions

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

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.
static final int rd_signing = 1
 Specify which expiry date shall be used by getRemainingDays(): Use the expiry date for signing documents.
static final int f_map_into_memory = 0x01
 Flag for setFlags(): map input file into memory.

Protected Member Functions

void finalize () throws Throwable
 Finalize this object.

Static Package Functions

 [static initializer]
 Static initializer.

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

de.softpro.doc.SignDocDocumentLoader.SignDocDocumentLoader (  ) throws SignDocException

Constructor.


Member Function Documentation

de.softpro.doc.SignDocDocumentLoader.[static initializer] (  ) [static, package]

Static initializer.

Loads the implementation DLL.

synchronized SignDocDocument de.softpro.doc.SignDocDocumentLoader.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 de.softpro.doc.SignDocDocumentLoader.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 de.softpro.doc.SignDocDocumentLoader.finalize (  ) throws Throwable [protected]

Finalize this object.

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

static byte [] de.softpro.doc.SignDocDocumentLoader.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 de.softpro.doc.SignDocDocumentLoader.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 [] de.softpro.doc.SignDocDocumentLoader.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:
loadFontConfigEnvironment(), loadFontConfigFile(), loadFontConfigEnvironment(), loadFontConfigStream(), loadPdfFontConfigEnvironment(), loadPdfFontConfigFile(), loadPdfFontConfigEnvironment(), loadPdfFontConfigStream()
static String de.softpro.doc.SignDocDocumentLoader.getInstallationCode (  ) throws SignDocException [static]

Get the installation code needed for creating a license file.

Returns:
The installation code (ASCII only) if successful, null on error.
static String de.softpro.doc.SignDocDocumentLoader.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 de.softpro.doc.SignDocDocumentLoader.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 de.softpro.doc.SignDocDocumentLoader.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 de.softpro.doc.SignDocDocumentLoader.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 de.softpro.doc.SignDocDocumentLoader.initLicenseManager ( int  aWho1,
int  aWho2 
) throws SignDocException [static]

Initialize license management.

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

Deprecated:
Usage of license files is deprecated, please use a license key, see setLicenseKey().
Parameters:
[in]aWho1The first magic number for the product.
[in]aWho2The second magic number for the product.
See also:
setLicensekey()
static void de.softpro.doc.SignDocDocumentLoader.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 de.softpro.doc.SignDocDocumentLoader.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(), loadFontConfigFile(), loadFontConfigStream()
synchronized void de.softpro.doc.SignDocDocumentLoader.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(), loadFontConfigEnvironment(), loadFontConfigStream()
synchronized void de.softpro.doc.SignDocDocumentLoader.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(), loadFontConfigEnvironment(), loadFontConfigStream()
synchronized SignDocDocument de.softpro.doc.SignDocDocumentLoader.loadFromFile ( String  aPath,
boolean  aWritable 
) throws SignDocException

Load a document from a file.

Signing the document will overwrite the document, but see integer parameter "Optimize" 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_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.

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 de.softpro.doc.SignDocDocumentLoader.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 de.softpro.doc.SignDocDocumentLoader.loadPdfFontConfigEnvironment ( String  aName ) throws SignDocException

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

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

The font configuration for 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(), loadPdfFontConfigFile(), loadPdfFontConfigStream()
synchronized void de.softpro.doc.SignDocDocumentLoader.loadPdfFontConfigFile ( String  aPath ) throws SignDocException

Load font configuration for PDF documents from a file.

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

The font configuration for 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(), loadPdfFontConfigEnvironment(), loadPdfFontConfigStream()
synchronized void de.softpro.doc.SignDocDocumentLoader.loadPdfFontConfigStream ( java.io.InputStream  aStream,
String  aDirectory 
) throws SignDocException

Load font configuration for PDF documents from a stream.

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

The font configuration for 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(), loadPdfFontConfigEnvironment(), loadPdfFontConfigStream()
synchronized void de.softpro.doc.SignDocDocumentLoader.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() and loadTrustedCertificatesFromStream() are cumulative.

Parameters:
[in]aPathThe pathname of the file.
Returns:
true if successful, false on error.
See also:
loadTrustedCertificatesFromStream()
synchronized void de.softpro.doc.SignDocDocumentLoader.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()
synchronized int de.softpro.doc.SignDocDocumentLoader.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.
Todo:
getErrorMessage()
synchronized void de.softpro.doc.SignDocDocumentLoader.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 de.softpro.doc.SignDocDocumentLoader.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(), initLicenseManager()
static void de.softpro.doc.SignDocDocumentLoader.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 SignDocDocument.renderPageAsImage() and SignDocDocument.addSignature() 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(), initLicenseManager()

Member Data Documentation

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.

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

See also:
getRemainingDays(), rd_signing

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: