Foxit PDF SDK
FSLibrary Class Reference

Inherits NSObject.

Class Methods

(void) + destroy
 Release all resource allocated by Foxit PDF SDK Library.
More...
 
(BOOL) + enableJavaScript:
 Enable or disable javascript for PDF.
More...
 
(NSString *) + getVersion
 Get the version of current Foxit PDF SDK library.
More...
 
(FSErrorCode+ initialize:key:
 Initialize Foxit PDF SDK Library, with valid license information.
More...
 
(BOOL) + registerSecurityCallback:callback:
 Register a FSSecurityCallback object to Foxit PDF SDK for decryption of the PDFs with special encryption filters.
More...
 
(BOOL) + registerSignatureCallback:sub_filter:signature_callback:
 Register a third-party FSSignatureCallback object to Foxit PDF SDK for signing and verifying signature, along with the filter and sub filter name of the callback.
More...
 
(void) + registerXFAAppProviderCallback:
 Register an FSAppProviderCallback object to Foxit PDF SDK.
More...
 
(FSErrorCode+ reinitialize
 Reinitialize Foxit PDF SDK Library.
More...
 
(BOOL) + setActionCallback:
 Set a FSActionCallback object to Foxit PDF SDK, in aid of performing PDF actions.
More...
 
(BOOL) + setAnnotIconProviderCallback:
 Set a customized FSIconProviderCallback object to Foxit PDF SDK.
More...
 
(BOOL) + setCacheSize:
 Set the upper limit of PDF library cache size.
More...
 
(BOOL) + setDocEventCallback:
 Set a object to Foxit PDF SDK.
More...
 
(void) + setLogFile:
 Set the log file path.
More...
 
(BOOL) + setNotifierCallback:
 Set a object to Foxit PDF SDK.
More...
 
(void) + setRenderTextGamma:
 Set gamma value for text rendering.
More...
 
(BOOL) + unregisterSecurityCallback:
 Unregister a FSSecurityCallback 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 FSLibrary::initialize:key: before calling any other Foxit PDF SDK functions. When there is no need to use Foxit PDF SDK any more, please call function FSLibrary::destroy. 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 FSErrFile to know more about what error occurs.

Method Documentation

◆ destroy()

+ (void) destroy

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 FSLibrary::initialize:key: again.

Returns
None.

◆ enableJavaScript:()

+ (BOOL) enableJavaScript: (BOOL)  enable_javascript

Enable or disable javascript for PDF.

Javascript for PDF is enabled by default.

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

◆ getVersion()

+ (NSString *) getVersion

Get the version of current Foxit PDF SDK library.

Returns
Version string.

◆ initialize:key:()

+ (FSErrorCode) initialize: (NSString *)  sn
key: (NSString *)  key 

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
FSErrSuccess means success.
FSErrInvalidLicense means input license information is invalid.
FSErrParam means parameter sn or key is an empty string.
For more information about error code values, please refer to values starting from FSErrSuccess.

◆ registerSecurityCallback:callback:()

+ (BOOL) registerSecurityCallback: (NSString *)  filter
callback: (id<FSSecurityCallback>)  callback 

Register a FSSecurityCallback 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.

Parameters
[in]filterThe filter name of the security callback object. This should not be nil or an empty string.
When users implement security callback of FSCustomSecurityCallback, users could specified their own custom filter string, but need to follow the PDF name conventions.
When users implement security callback of FSCertificateSecurityCallback, the filter value must be set to "Adobe.PubSec".
When users implement security callback of FSDRMSecurityCallback, the filter value must be set to "FoxitDRM", or some error may occur later.
When users implement security callback of FSRMSSecurityCallback, the filter value must be set to "MicrosoftIRMServices", or some error may occur later.
[in]callbackA FSSecurityCallback object, which is implemented by user and based on callback class FSSecurityCallback. User should not inherit FSSecurityCallback directly, but inherit its derived class, such as FSCustomSecurityCallback, FSCertificateSecurityCallback, etc.
Returns
YES means success, while NO means failure.
Note
If module "RMS" is not defined in the license information which is used in function FSLibrary::initialize:key:, that means user has no right in using RMS related functions and this function will throw exception FSErrInvalidLicense.

◆ registerSignatureCallback:sub_filter:signature_callback:()

+ (BOOL) registerSignatureCallback: (NSString *)  filter
sub_filter: (NSString *)  sub_filter
signature_callback: (id<FSSignatureCallback>)  signature_callback 

Register a third-party FSSignatureCallback 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"

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 FSSignatureCallback object, which is implemented by user and based on callback class FSSignatureCallback. 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 FSLibrary::destroy.
If this is nil, that means the registered third-party callback is to be removed from Foxit PDF SDK.
Returns
YES means success, while NO means failure.

◆ registerXFAAppProviderCallback:()

+ (void) registerXFAAppProviderCallback: (id<FSAppProviderCallback>)  callback

Register an FSAppProviderCallback object to Foxit PDF SDK.

This function should be called first before processing XFA document.

Parameters
[in]callbackAn FSAppProviderCallback object, which is implemented by user and based on callback class FSAppProviderCallback. 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 FSLibrary::destroy.
Returns
None.
Note
If module "XFA" is not defined in the license information which is used in function FSLibrary::initialize:key:, that means user has no right in using XFA related functions and this function will throw exception FSErrInvalidLicense.

◆ reinitialize()

+ (FSErrorCode) reinitialize

Reinitialize Foxit PDF SDK Library.

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

Returns
FSErrSuccess means success. For more information about error code values, please refer to values starting from FSErrSuccess.

◆ setActionCallback:()

+ (BOOL) setActionCallback: (id<FSActionCallback>)  action_callback

Set a FSActionCallback 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 FSActionCallback object. nil 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
YES means success, while NO means failure.

◆ setAnnotIconProviderCallback:()

+ (BOOL) setAnnotIconProviderCallback: (id<FSIconProviderCallback>)  annot_icon_provider

Set a customized FSIconProviderCallback 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 FSIconProviderCallback. If this is nil, 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 FSLibrary::destroy is called.
Returns
YES means success, while NO 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 FSIconProviderCallback::getProviderID and FSIconProviderCallback::getProviderVersion.

◆ setCacheSize:()

+ (BOOL) setCacheSize: (unsigned int)  size

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
YES means success, while NO means failure.

◆ setDocEventCallback:()

+ (BOOL) setDocEventCallback: (id<FSDocEventCallback>)  callback

Set a object to Foxit PDF SDK.

Parameters
[in]callbackA object. nil means not use any document event callback object.
Returns
YES means success, while NO means failure.

◆ setLogFile:()

+ (void) setLogFile: (NSString *)  log_file_path

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:()

+ (BOOL) setNotifierCallback: (id<FSNotifierCallback>)  notifier

Set a 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 object. User should ensure all the callback functions have been implemented in application level.
Returns
YES means success, while NO means failure.

◆ setRenderTextGamma:()

+ (void) setRenderTextGamma: (float)  gamma

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:()

+ (BOOL) unregisterSecurityCallback: (NSString *)  filter

Unregister a FSSecurityCallback object from Foxit PDF SDK.

Parameters
[in]filterThe filter name which is used for registering a security callback object. Please refer to comment of parameter filter in function FSLibrary::registerSecurityCallback:callback:.
Returns
YES means success, while NO means failure.
Note
If module "RMS" is not defined in the license information which is used in function FSLibrary::initialize:key:, that means user has no right in using RMS related functions and this function will throw exception FSErrInvalidLicense.