public class PDFLibrary
extends java.lang.Object
PDFLibrary
class offers methods to initialize and unlock the
SDK.
Foxit PDF SDK manages a license control mechanism to determine how to run for
the application purpose.
Foxit PDF SDK license should be purchased for the application and pass unlock
key and code to get proper supports.
It can be constructed by the following way.
Example:
PDFLibrary pdfLibrary = PDFLibrary.getInstance();
Modifier and Type | Field and Description |
---|---|
static int |
LICENSETYPE_AUTHORIZED
Authorized license.
|
static int |
LICENSETYPE_EVALUATION
Evaluation license.
|
static int |
LICENSETYPE_EXPIRED
Expired license.
|
static int |
LICENSETYPE_INVALID
Invalid license.
|
static int |
OBJECTTYPE_DOCUMENT
Document type.
|
static int |
OBJECTTYPE_PAGE
Page type.
|
static int |
OBJECTTYPE_PSI
Pressure sensitive ink type.
|
Modifier and Type | Method and Description |
---|---|
void |
addFontFile(FileHandler fontFile)
Add an additional font (typically a TrueType, Type1 or CFF font) to Foxit
PDF SDK library.
|
void |
destroy()
Finalize PDF module.
|
static PDFLibrary |
getInstance()
Get the
PDFLibrary object. |
int |
getLicenseType()
Get the current license type.
|
void |
initialize(int memorySize,
boolean scaleable)
Initialize the Foxit PDF SDK library.
|
static void |
oomRecover(PDFDocument document)
Recover the user operations when SDK ran out of memory.
|
static void |
setAppHandler(IApp app)
Register the
IApp handler to Foxit PDF SDK library to
support extension functions and events. |
static void |
triggerRecover(java.lang.Object object,
int objectType)
Trigger a recovery operation for the specified object.
|
void |
unlock(java.lang.String licenseKey,
java.lang.String unlockCode)
Unlock Foxit PDF SDK library with license key and code.
|
public static final int LICENSETYPE_INVALID
unlock(String, String)
or license
key/code is wrong.public static final int LICENSETYPE_AUTHORIZED
public static final int LICENSETYPE_EVALUATION
public static final int LICENSETYPE_EXPIRED
public static final int OBJECTTYPE_DOCUMENT
public static final int OBJECTTYPE_PAGE
public static final int OBJECTTYPE_PSI
public static PDFLibrary getInstance()
PDFLibrary
object.PDFLibrary
object.public void initialize(int memorySize, boolean scaleable) throws PDFException
Applications should call this function to initialize Foxit PDF SDK library at first.It will cause unexpected errors to call other functions before this one.
memorySize
- A pre-allocated memory buffer to initialize Foxit PDF SDK. In
bytes, it should be 8MB at least.scaleable
- A boolean value specifies whether the memory size is scaled or
not. It means when SDK ran out of the pre-allocated memory,
whether the SDK can be realloc the needed size of memory or
not.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void unlock(java.lang.String licenseKey, java.lang.String unlockCode) throws PDFException
Applications should call this function to unlock library. This function should be called after Foxit PDF SDK library is initialized successfully.
licenseKey
- A String
object that specifies license key value.unlockCode
- A String
object that specifies license code value.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void destroy()
This function releases all internal resources and frees the current Foxit
PDF SDK Library.
This function should be called after Foxit PDF SDK library is unlocked
successfully.
public void addFontFile(FileHandler fontFile) throws PDFException
This function can be called multiple times, each time to add a font to
Foxit PDF SDK Library. When calling the function
to create
a font or display a document which has non-embedded fonts, Foxit PDF SDK
Library will search a font from system fonts and also search all fonts
added by this function.FontManager.create(String, int, int, int)
fontFile
- A FileHandler
object that is the font file to be added.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
FileHandler
public int getLicenseType() throws PDFException
Applications should call the function
to unlock a library.unlock(String, String)
Using this function to determine which type of license can be accepted.
Please purchase authorized Foxit PDF SDK licenses.
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public static void setAppHandler(IApp app) throws PDFException
IApp
handler to Foxit PDF SDK library to
support extension functions and events. Specially for callback function
of OOM Recover.app
- A IApp
interface to register the handler to
library.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
IApp
public static void oomRecover(PDFDocument document) throws PDFException
When SDK ran out of the memory, typically the return value of current
function will be one of the follows:
,
PDFException.ERRCODE_MEMORYREBUILT
,
PDFException.ERRCODE_UNRECOVERABLE
or
PDFException.ERRCODE_OUTOFMEMORY
, applications should call this
function to prepare the recover environment and re-do the operations in
the callback function
Progress.ROLLBACK
in IApp.java.IApp.onRecover(Object, PDFDocument)
document
- A PDFDocument
object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFDocument
,
IApp
,
PDFException
public static void triggerRecover(java.lang.Object object, int objectType) throws PDFException
When SDK ran out of memory, applications can
call this function to recover the basic objects first, like
PDFDocument
, PDFPage
and so on, before call
the function
.oomRecover(PDFDocument)
object
- A sender object, relative to parameter objectType
.
Currently available object is PDFDocument
or PDFPage
.objectType
- Object type of parameter object
.
Currently available value is OBJECTTYPE_DOCUMENT
or OBJECTTYPE_PAGE
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFDocument
,
PDFPage