java.lang.Object | |
↳ | com.pdftron.pdf.PDFNet |
PDFNet contains global library initialization, registration, configuration, and termination methods.
Note: There is only a single, static instance of PDFNet class. Initialization and termination methods need to be called only once per application session.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | e_CNS1 | Character ordering: Chinese; Traditional | |||||||||
int | e_GB1 | Character ordering: Chinese; Simplified | |||||||||
int | e_Identity | Character ordering: Generic/Unicode | |||||||||
int | e_Japan1 | Character ordering: Japanese | |||||||||
int | e_Japan2 | Character ordering: Japanese | |||||||||
int | e_Korea1 | Character ordering: Korean | |||||||||
int | e_icm | Use Windows ICM2 (available only on Windows platforms). | |||||||||
int | e_lcms | Use LittleCMS (available on all supported platforms). | |||||||||
int | e_no_cms | No ICC color management. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
PDFNet() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static boolean |
IsARM()
Check if the platform is older ARM compatible.
| ||||||||||
static boolean |
IsARMv7()
Check if the platform is ARM v7 compatible.
| ||||||||||
static boolean |
addFontSubst(int ordering, String fontpath)
This method is deprecated.
Use
addResourceSearchPath(String) instead.
Adds the font substitute | ||||||||||
static boolean |
addFontSubst(String fontname, String fontpath)
This method is deprecated.
Use
addResourceSearchPath(String) instead.
AddFontSubst functions can be used to create font substitutes that can
override default PDFNet font selection algorithm.
These functions are useful in situations where referenced fonts are not present in the document and PDFNet font substitution algorithm is not producing desired results. AddFontSubst(fontname, fontpath) maps the given font name (i.e. 'BaseFont' entry from the font dictionary) to a font file. AddFontSubst(ordering, fontpath) maps the given character ordering (see Ordering entry in CIDSystemInfo dictionary; Section 5.6.2 in PDF Reference) to a font file. This method is less specific that the former variant of AddFontSubst, and can be used to override a range of missing fonts (or any missing font) with a predefined substitute. The following is an example of using these functions to provide user defined font substitutes:
| ||||||||||
static void |
addPDFTronCustomHandler(int custom_id)
Add PDFTron Custom Security handler
| ||||||||||
static void |
addResourceSearchPath(String path)
Set the location of PDFNet resources file.
| ||||||||||
static void |
enableJavaScript(boolean enable)
A switch that can be used to turn on/off JavaScript engine
| ||||||||||
static String |
getResourcesPath()
Get the resources path.
| ||||||||||
static String |
getSystemFontList()
Get available fonts on the system.
| ||||||||||
static double |
getVersion()
Get the version.
| ||||||||||
static String | getVersionString() | ||||||||||
static boolean |
hasBeenInitialized()
Returns true if PDFNet has been initialized.
| ||||||||||
static void |
initialize(Context context, int resId, String license_key)
Initializes PDFNet library.
| ||||||||||
static void |
initialize(String license_key)
Should be used for license validation check only.
| ||||||||||
static boolean |
isJavaScriptEnabled()
Test whether JavaScript is enabled
| ||||||||||
static void |
setColorManagement(int t)
Used to set a specific Color Management System (CMS) for use during color
conversion operators, image rendering, etc.
| ||||||||||
static void |
setDefaultDeviceCMYKProfile(String icc_filename)
Set the default ICC color profile for DeviceCMYK color space.
| ||||||||||
static void |
setDefaultDeviceRGBProfile(String icc_filename)
Set the default ICC color profile for DeviceRGB color space.
| ||||||||||
static void |
setDefaultDiskCachingEnabled(boolean use_disk)
Sets the default policy on using temporary files.
| ||||||||||
static void |
setPersistentCachePath(String temp_path)
Set the location of persistent cache files.
| ||||||||||
static boolean |
setResourcesPath(String path)
Set the location of PDFNet resources file.
| ||||||||||
static void |
setTempPath(String temp_path)
Set the location of temporary folder.
| ||||||||||
static void |
setViewerCache(int max_cache_size, boolean on_disk)
Sets the default parameters of the cache used to render a PDFDoc
instance.
| ||||||||||
static void |
terminate()
Terminates PDFNet library.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Character ordering: Chinese; Traditional
Character ordering: Chinese; Simplified
Character ordering: Generic/Unicode
Character ordering: Japanese
Character ordering: Japanese
Character ordering: Korean
Use Windows ICM2 (available only on Windows platforms).
Use LittleCMS (available on all supported platforms).
No ICC color management.
Check if the platform is older ARM compatible.
Check if the platform is ARM v7 compatible.
This method is deprecated.
Use addResourceSearchPath(String)
instead.
Adds the font substitute
ordering | the ordering |
---|---|
fontpath | path to font |
PDFNetException |
---|
This method is deprecated.
Use addResourceSearchPath(String)
instead.
AddFontSubst functions can be used to create font substitutes that can
override default PDFNet font selection algorithm.
These functions are useful in situations where referenced fonts are not present in the document and PDFNet font substitution algorithm is not producing desired results.
AddFontSubst(fontname, fontpath) maps the given font name (i.e. 'BaseFont' entry from the font dictionary) to a font file.
AddFontSubst(ordering, fontpath) maps the given character ordering (see Ordering entry in CIDSystemInfo dictionary; Section 5.6.2 in PDF Reference) to a font file. This method is less specific that the former variant of AddFontSubst, and can be used to override a range of missing fonts (or any missing font) with a predefined substitute.
The following is an example of using these functions to provide user defined font substitutes:
PDFNet.initialize();
PDFNet.setResourcesPath("c:/myapp/resources");
// Specify specific font mappings...
PDFNet.addFontSubst("MinionPro-Regular", "c:/myfonts/MinionPro-Regular.otf");
PDFNet.addFontSubst("Times-Roman", "c:/windows/fonts/times.ttf");
PDFNet.addFontSubst("Times-Italic", "c:/windows/fonts/timesi.ttf");
// Specify more general font mappings...
// Arial Unicode MS
PDFNet.addFontSubst(PDFNet.e_Identity, "c:/myfonts/arialuni.ttf");
PDFNet.addFontSubst(PDFNet.e_Japan1, "c:/myfonts/KozMinProVI-Regular.otf");
PDFNet.addFontSubst(PDFNet.e_Japan2, "c:/myfonts/KozMinProVI-Regular.otf");
PDFNet.addFontSubst(PDFNet.e_Korea1, "c:/myfonts/AdobeSongStd-Light.otf");
PDFNet.addFontSubst(PDFNet.e_CNS1, "c:/myfonts/AdobeMingStd-Light.otf");
PDFNet.addFontSubst(PDFNet.e_GB1, "c:/myfonts/AdobeMyungjoStd-Medium.otf");
//...
PDFDoc doc = new PDFDoc("c:/my.pdf");
//...
fontname | the fontname |
---|---|
fontpath | path to font |
PDFNetException |
---|
Add PDFTron Custom Security handler
custom_id | The user's custom id. The id should match what was used to create PDFTronCustomSecurityHandler when encrypting the document. Note: calling this function is a requirement to load files encrypted with PDFTronCustomSecurityHandler. |
---|
PDFNetException |
---|
Set the location of PDFNet resources file.
Note: Add a path that will be searched when PDFNet requires additional resources such as fonts. Will not remove any existing search paths (so that multiple paths may be specified)
path | The new path to add to the resource search paths. |
---|
A switch that can be used to turn on/off JavaScript engine
enable | true to enable JavaScript engine, false to disable. |
---|
Get the resources path.
PDFNetException |
---|
Get available fonts on the system.
PDFNetException |
---|
Returns true if PDFNet has been initialized.
Initializes PDFNet library. Initialize() is usually called once, during process initialization.
Note: It is unsafe to call any other PDFNet API without first initializing the library.
context | The Context the activity is running in, through which it can access the current theme, resources, etc. It can be either an Application or an Activity context. |
---|---|
resId | The resource ID for the PDFNet resources file (pdfnet.res).
If this parameter is used, PDFNet will use the provided
resource file. If not, some PDF documents may not render
correctly. Note that the resource file name should be
"pdfnet.res" when placing it under res/raw folder. Also,
if it is desirable to store the resources file outside the
package, it is possible to use setResourcesPath(String)
in order to set the path to where the resources file is
located. |
license_key | Nullable license key used to activate the product. If the license_key is null or empty, the product will work in demo mode. If the license_key is invalid, the product will work in demo mode. |
PDFNetException | It can throw exception in the following cases:
|
---|
Should be used for license validation check only. This method will throw if license key is invalid.
Test whether JavaScript is enabled
Used to set a specific Color Management System (CMS) for use during color conversion operators, image rendering, etc.
t | identifies the type of color management to use. |
---|
PDFNetException |
---|
Set the default ICC color profile for DeviceCMYK color space.
Note: You can use this method to override default PDFNet settings. For more information on default color spaces please refer to section 'Default Color Spaces' in Chapter 4.5.4 of PDF Reference Manual.
icc_filename | the new default device CMYK profile |
---|
PDFNetException |
---|
Set the default ICC color profile for DeviceRGB color space.
Note: You can use this method to override default PDFNet settings. For more information on default color spaces please refer to section 'Default Color Spaces' in Chapter 4.5.4 of PDF Reference Manual.
icc_filename | the new default device RGB profile |
---|
PDFNetException |
---|
Sets the default policy on using temporary files.
use_disk | if parameter is true then new documents are allowed to create temporary files; otherwise all document contents will be stored in memory. |
---|
PDFNetException |
---|
Set the location of persistent cache files. By default, it is set to context.getFilesDir().getPath().
This method is provided for applications that require tight control of the location where temporary files are created.
temp_path | path to persistent cache folder |
---|
PDFNetException |
---|
Set the location of PDFNet resources file.
Note: Starting with version 6.0.0 the resources (Fonts, CMaps, and standard PDF resources) were separated from the libraries on the PDFNet Android SDK. As a result, it is necessary to either initialize PDFNet passing the resource ID or set the path to the resources file using this method. Failing to set the resources file might result in wrong rendering of certain documents. The function can be also used to specify a default search path for ICC profiles, fonts, and other user defined resources.
path | The default resource directory path. |
---|
Set the location of temporary folder. By default, it is set to context.getCacheDir().getPath(). Files saved to this location can be deleted by the OS when the disk space is low.
This method is provided for applications that require tight control of the location where temporary files are created.
temp_path | path to temporary folder |
---|
PDFNetException |
---|
Sets the default parameters of the cache used to render a PDFDoc instance. Any subsequently created documents will use these parameters. Caching is especially useful for interactive rendering, say in com.pdftron.pdf.PDFViewCtrl.
Note: Setting max_cache_size to zero will disable the cache.
max_cache_size | The maximum size, in bytes, of the entire document's page cache. Set to zero to disable the viewer cache. The maximum cache size is 100 MB. |
---|---|
on_disk | If set to true, cache will be stored on the local filesystem. If set to 'false', cache will be stored in heap memory. The default value is false. |
Terminates PDFNet library. It is usually called once, when the process is terminated.
Note: It is unsafe to call any other PDFNet API after you terminate the library.