Foxit PDF SDK
com.foxit.sdk.common.Library Class Reference

Static Public Member Functions

static boolean enableJavaScript (boolean enable_javascript)
 Enable or disable javascript for PDF.
More...
 
static String getVersion ()
 Get the version of current Foxit PDF SDK library.
More...
 
static boolean hasModuleLicenseRight (int module_name) throws com.foxit.sdk.PDFException
 Check if user has right to use a specified module of Foxit PDF SDK in current used license information (which is used to initialize Foxit PDF SDK).
More...
 
static int initialize (String sn, String key)
 Initialize Foxit PDF SDK Library, with valid license information.
More...
 
static boolean registerSecurityCallback (String filter, SecurityCallback callback) throws com.foxit.sdk.PDFException
 Register a com.foxit.sdk.pdf.SecurityCallback object to Foxit PDF SDK for decryption of the PDFs with special encryption filters.
More...
 
static boolean registerSignatureCallback (String filter, String sub_filter, SignatureCallback signature_callback) throws com.foxit.sdk.PDFException
 Register a third-party com.foxit.sdk.pdf.SignatureCallback object to Foxit PDF SDK for signing and verifying signature, along with the filter and sub filter name of the callback.
More...
 
static void registerXFAAppProviderCallback (AppProviderCallback callback) throws com.foxit.sdk.PDFException
 Register an com.foxit.sdk.addon.xfa.AppProviderCallback object to Foxit PDF SDK.
More...
 
static int reinitialize ()
 Reinitialize Foxit PDF SDK Library.
More...
 
static void release ()
 Release all resource allocated by Foxit PDF SDK Library.
More...
 
static boolean setActionCallback (ActionCallback action_callback)
 Set a com.foxit.sdk.ActionCallback object to Foxit PDF SDK, in aid of performing PDF actions.
More...
 
static boolean setAnnotIconProviderCallback (IconProviderCallback annot_icon_provider)
 Set a customized com.foxit.sdk.pdf.annots.IconProviderCallback object to Foxit PDF SDK.
More...
 
static boolean setCacheSize (int size)
 Set the upper limit of PDF library cache size.
More...
 
static boolean setDocEventCallback (DocEventCallback callback)
 Set a DocEventCallback object to Foxit PDF SDK.
More...
 
static boolean setFontMapperCallback (FontMapperCallback callback)
 Set a FontMapperCallback object to Foxit PDF SDK.
More...
 
static void setLogFile (String log_file_path)
 Set the log file path.
More...
 
static boolean setNotifierCallback (NotifierCallback notifier)
 Set a NotifierCallback object to Foxit PDF SDK.
More...
 
static void setRenderTextGamma (float gamma)
 Set gamma value for text rendering.
More...
 
static boolean unregisterSecurityCallback (String filter) throws com.foxit.sdk.PDFException
 Unregister a com.foxit.sdk.pdf.SecurityCallback object from Foxit PDF SDK.
More...
 

Detailed Description

This class represents the library management. It contains functions to initialize/re-initialize/release Foxit PDF SDK library, and also contains functions for global use.
Any application should load Foxit PDF SDK by function Library.initialize before calling any other Foxit PDF SDK functions. When there is no need to use Foxit PDF SDK any more, please call function Library.release . Functions in Foxit PDF SDK may throw exception when some error occurs. User can catch these exceptions and check the error code with values starting from com.foxit.sdk.common.Constants.e_ErrFile to know more about what error occurs.

Member Function Documentation

◆ enableJavaScript()

static boolean com.foxit.sdk.common.Library.enableJavaScript ( boolean  enable_javascript)
static

Enable or disable javascript for PDF.

Javascript for PDF is enabled by default.

Parameters
[in]enable_javascripttrue means to enable javascript, and false means to disable javascript. If this function is not called, javascript for PDF is enabled by default.
Returns
true means success, while false means failure.

◆ getVersion()

static String com.foxit.sdk.common.Library.getVersion ( )
static

Get the version of current Foxit PDF SDK library.

Returns
Version string.

◆ hasModuleLicenseRight()

static boolean com.foxit.sdk.common.Library.hasModuleLicenseRight ( int  module_name) throws com.foxit.sdk.PDFException
static

Check if user has right to use a specified module of Foxit PDF SDK in current used license information (which is used to initialize Foxit PDF SDK).

In Foxit PDF SDK, once the library is initialized successfully, most feature can be used. But for some special features, they can be used only when specified modules are defined in license information. This function can be used to check if user has right for these special modules before using these feature.

Parameters
[in]module_nameName of the module whose right is to be checked. Please refer to values starting from com.foxit.sdk.common.Constants.e_ModuleNameConnectedPDF and this should be one of these values.
Returns
true means user has right to use the specified module, while false means user does not have right to use the specified module.

◆ initialize()

static int com.foxit.sdk.common.Library.initialize ( String  sn,
String  key 
)
static

Initialize Foxit PDF SDK Library, with valid license information.

This function should be called first before any other functions in Foxit PDF SDK can be called.

Parameters
[in]snString of sn information, which can be retrieved from "SN=" part in key file "gsdk_sn.txt" or "rdk_sn.txt".
[in]keyString of key information, which can be retrieved from "Sign=" part in key file "gsdk_key.txt" or "rdk_key.txt".
Returns
com.foxit.sdk.common.Constants.e_ErrSuccess means success.
com.foxit.sdk.common.Constants.e_ErrInvalidLicense means input license information is invalid.
com.foxit.sdk.common.Constants.e_ErrParam means parameter sn or key is an empty string.
For more information about error code values, please refer to values starting from com.foxit.sdk.common.Constants.e_ErrSuccess .

◆ registerSecurityCallback()

static boolean com.foxit.sdk.common.Library.registerSecurityCallback ( String  filter,
SecurityCallback  callback 
) throws com.foxit.sdk.PDFException
static

Register a com.foxit.sdk.pdf.SecurityCallback object to Foxit PDF SDK for decryption of the PDFs with special encryption filters.

When this function is successful, Foxit PDF SDK will take over the input security callback object and user should not release this callback object directly anymore; otherwise unexpected crash may occurs later.
Foxit PDF SDK may release the security callback object by callback function pdf.SecurityCallback.release , when unregister it and find that it has not been used by other object. So, user is recommended not to use the security callback object any more after function Library.unregisterSecurityCallback .

Parameters
[in]filterThe filter name of the security callback object. This should not be null or an empty string.
When users implement security callback of com.foxit.sdk.pdf.CustomSecurityCallback , users could specified their own custom filter string, but need to follow the PDF name conventions.
When users implement security callback of com.foxit.sdk.pdf.CertificateSecurityCallback , the filter value must be set to "Adobe.PubSec".
When users implement security callback of com.foxit.sdk.pdf.DRMSecurityCallback , the filter value must be set to "FoxitDRM", or some error may occur later.
When users implement security callback of com.foxit.sdk.pdf.RMSSecurityCallback , the filter value must be set to "MicrosoftIRMServices", or some error may occur later.
[in]callbackA com.foxit.sdk.pdf.SecurityCallback object, which is implemented by user and based on callback class com.foxit.sdk.pdf.SecurityCallback . User should not inherit com.foxit.sdk.pdf.SecurityCallback directly, but inherit its derived class, such as com.foxit.sdk.pdf.CustomSecurityCallback , com.foxit.sdk.pdf.CertificateSecurityCallback , etc.
Returns
true means success, while false means failure.
Note
If module "RMS" is not defined in the license information which is used in function Library.initialize , that means user has no right in using RMS related functions and this function will throw exception com.foxit.sdk.common.Constants.e_ErrInvalidLicense .

◆ registerSignatureCallback()

static boolean com.foxit.sdk.common.Library.registerSignatureCallback ( String  filter,
String  sub_filter,
SignatureCallback  signature_callback 
) throws com.foxit.sdk.PDFException
static

Register a third-party com.foxit.sdk.pdf.SignatureCallback object to Foxit PDF SDK for signing and verifying signature, along with the filter and sub filter name of the callback.

Foxit PDF SDK has default signature callbacks defined with 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"

If user wants to use a third-party signature callback, please call this function before signing or verifying signature process.
If user register a customized signature callback with the same filter and filter as default ones by this function, the default signature callback in Foxit PDF SDK will not have any effect any more.

Parameters
[in]filterThe filter name of the signature callback, in ASCII encoding. This should not be an empty string. Filter name is the name of the signature callback.
[in]sub_filterThe sub filter name of the signature callback, in ASCII encoding. Sub filter is to describe the encoding of signature value and key information in the signature dictionary.
[in]signature_callbackA customized com.foxit.sdk.pdf.SignatureCallback object, which is implemented by user and based on callback class com.foxit.sdk.pdf.SignatureCallback . User should ensure all the callback functions have been implemented in application level and should also ensure this signature callback object valid until Foxit PDF SDK is released by function Library.release .
If this is null, that means the registered third-party callback is to be removed from Foxit PDF SDK.
Returns
true means success, while false means failure.

◆ registerXFAAppProviderCallback()

static void com.foxit.sdk.common.Library.registerXFAAppProviderCallback ( AppProviderCallback  callback) throws com.foxit.sdk.PDFException
static

Register an com.foxit.sdk.addon.xfa.AppProviderCallback object to Foxit PDF SDK.

This function should be called first before processing XFA document.

Parameters
[in]callbackAn com.foxit.sdk.addon.xfa.AppProviderCallback object, which is implemented by user and based on callback class com.foxit.sdk.addon.xfa.AppProviderCallback . User should ensure all the callback functions have been implemented in application level and should also ensure this XFA application provider callback object valid until Foxit PDF SDK is released by function Library.release .
Returns
None.
Note
If module "XFA" is not defined in the license information which is used in function Library.initialize , that means user has no right in using XFA related functions and this function will throw exception com.foxit.sdk.common.Constants.e_ErrInvalidLicense .

◆ reinitialize()

static int com.foxit.sdk.common.Library.reinitialize ( )
static

Reinitialize Foxit PDF SDK Library.

When user meets out-of-memory error, user can call this function to reinitialize Foxit PDF SDK Library.

Returns
com.foxit.sdk.common.Constants.e_ErrSuccess means success. For more information about error code values, please refer to values starting from com.foxit.sdk.common.Constants.e_ErrSuccess .

◆ release()

static void com.foxit.sdk.common.Library.release ( )
static

Release all resource allocated by Foxit PDF SDK Library.

User can call this function to release all memory blocks allocated by the library. After this function is called, user should not use Foxit PDF SDK any more until call Library.initialize again.

Returns
None.

◆ setActionCallback()

static boolean com.foxit.sdk.common.Library.setActionCallback ( ActionCallback  action_callback)
static

Set a com.foxit.sdk.ActionCallback object to Foxit PDF SDK, in aid of performing PDF actions.

User should implement an action callback object and call this function to set the action callback object to Foxit PDF SDK if PDF actions need to be performed, such as filling a PDF form.

Parameters
[in]action_callbackA customized com.foxit.sdk.ActionCallback object. null means not use any action callback object. User should ensure all the callback functions have been implemented in application level. If this is a valid action callback object, Foxit PDF SDK will take over the management of this callback object and user should not release it directly.
Returns
true means success, while false means failure.

◆ setAnnotIconProviderCallback()

static boolean com.foxit.sdk.common.Library.setAnnotIconProviderCallback ( IconProviderCallback  annot_icon_provider)
static

Set a customized com.foxit.sdk.pdf.annots.IconProviderCallback object to Foxit PDF SDK.

User can call this function to set a customized icon provider for annotation. If this function has been called several times, Foxit PDF SDK will only keep the last icon provider. If this function has not been called even once, Foxit PDF SDK will use the default standard icon provider.

Parameters
[in]annot_icon_providerA customized annotation icon provider, which is implemented based on callback class com.foxit.sdk.pdf.annots.IconProviderCallback . If this is null, customized annotation icon provider will be removed from Foxit PDF SDK and default standard icon provider will be used instead. Application should ensure this icon provider object valid until it has been removed from Foxit PDF SDK or function Library.release is called.
Returns
true means success, while false means failure.
Note
Icon provider's ID and version are treated as the name of the icon provider, so please offer different "ID + version" for different icon providers by callback functions pdf.annots.IconProviderCallback.getProviderID and pdf.annots.IconProviderCallback.getProviderVersion .

◆ setCacheSize()

static boolean com.foxit.sdk.common.Library.setCacheSize ( int  size)
static

Set the upper limit of PDF library cache size.

If no cache size limit is set by application, the cache size will be set to 200 MegaBytes internally by default.

Parameters
[in]sizeThe upper limit of the cache, in MegaBytes, 0~4096. If set to 0, that means not to use limit of cache size.
Returns
true means success, while false means failure.

◆ setDocEventCallback()

static boolean com.foxit.sdk.common.Library.setDocEventCallback ( DocEventCallback  callback)
static

Set a DocEventCallback object to Foxit PDF SDK.

Parameters
[in]callbackA DocEventCallback object. null means not use any document event callback object.
Returns
true means success, while false means failure.

◆ setFontMapperCallback()

static boolean com.foxit.sdk.common.Library.setFontMapperCallback ( FontMapperCallback  callback)
static

Set a FontMapperCallback object to Foxit PDF SDK.

Once a valid custom font mapper callback is set to Foxit PDF SDK, Foxit PDF SDK will first use this callback when mapping a font.

Parameters
[in]callbackA FontMapperCallback object. null means not use any custom font mapper callback object.
Returns
true means success, while false means failure.

◆ setLogFile()

static void com.foxit.sdk.common.Library.setLogFile ( String  log_file_path)
static

Set the log file path.

After a log file path is set to Foxit PDF SDK, all the logs will be written to the log file. Currently, the log information in Foxit PDF SDK is simple; this will be improved in future version.

Parameters
[in]log_file_pathA log file path.
Returns
None.

◆ setNotifierCallback()

static boolean com.foxit.sdk.common.Library.setNotifierCallback ( NotifierCallback  notifier)
static

Set a NotifierCallback object to Foxit PDF SDK.

User can call this function to set a notifier callback object to Foxit PDF SDK, so that when events (such as OOM) happens, user would be notified.

Parameters
[in]notifierA NotifierCallback object. User should ensure all the callback functions have been implemented in application level.
Returns
true means success, while false means failure.

◆ setRenderTextGamma()

static void com.foxit.sdk.common.Library.setRenderTextGamma ( float  gamma)
static

Set gamma value for text rendering.

If this function is not called to set gamma value, Foxit PDF SDK will use 2.2 as the default value.

Parameters
[in]gammaGamma value. It should be greater than 0.
Returns
None.

◆ unregisterSecurityCallback()

static boolean com.foxit.sdk.common.Library.unregisterSecurityCallback ( String  filter) throws com.foxit.sdk.PDFException
static

Unregister a com.foxit.sdk.pdf.SecurityCallback object from Foxit PDF SDK.

Foxit PDF SDK may release the security callback function by callback function pdf.SecurityCallback.release , when unregister it and find that it has not been used by other object. So, user is recommended not to use the security callback object any more after function Library.unregisterSecurityCallback .

Parameters
[in]filterThe filter name which is used for registering a security callback object. Please refer to comment of parameter filter in function Library.registerSecurityCallback .
Returns
true means success, while false means failure.
Note
If module "RMS" is not defined in the license information which is used in function Library.initialize , that means user has no right in using RMS related functions and this function will throw exception com.foxit.sdk.common.Constants.e_ErrInvalidLicense .