public class

PDFNet

extends Object
java.lang.Object
   ↳ com.pdftron.pdf.PDFNet

Class Overview

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.

Summary

Constants
int e_CNS1 The Constant e_CNS1.
int e_ConnectionErrorHandlingMode_continue
int e_ConnectionErrorHandlingMode_continue_unless_switching_to_demo
int e_ConnectionErrorHandlingMode_stop
int e_GB1 The Constant e_GB1.
int e_Identity Standard character orderings.
int e_Japan1 The Constant e_Japan1.
int e_Japan2 The Constant e_Japan2.
int e_Korea1 The Constant e_Korea1.
int e_LogLevel_Debug
int e_LogLevel_Error
int e_LogLevel_Fatal
int e_LogLevel_Info
int e_LogLevel_Off
int e_LogLevel_Trace
int e_LogLevel_Warning
int e_icm The Constant e_icm.
int e_lcms The Constant e_lcms.
int e_no_cms The Constant e_no_cms.
int e_status_bad_Credentials
int e_status_err
int e_status_invalid_operation
int e_status_network_err
int e_status_ok
int e_status_service_down
int e_z_best_compression
int e_z_best_speed
int e_z_default_compression
int e_z_no_compression
Public Constructors
PDFNet()
Public Methods
static boolean addFontSubst(int ordering, String fontpath)
Adds the font substitute
static boolean addFontSubst(String fontname, String fontpath)
AddFontSubst functions can be used to create font substitutes that can override default PDFNet font selection algorithm.
static void addPDFTronCustomHandler(int custom_id)
Add PDFTron Custom Security handler
static void addResourceSearchPath(String path)
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 void initialize(String license_key)
Initializes PDFNet library.
static void initialize()
Initializes PDFNet library.
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 setConnectionErrorHandlingMode(int mode)
Sets the connection error handling behaviour for Apryse SDK The default for this method is e_continue
static void setConnectionErrorProc(ConnectionErrorProc error_proc, Object data)
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 setDefaultFlateCompressionLevel(int level)
Sets the default compression level for Flate (ZLib).
static void setLogLevel(int level)
static void setPersistentCachePath(String persistent_path)
Set the location of persistent cache files This method is provided for applications that require tight control of the location where temporary files are created.
static boolean setResourcesPath(String path)
Set the location of PDFNet resource 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 for the viewer cache.
static void setWriteAPIUsageLocally(boolean write_usage)
Enable writing API usage locally.
static void terminate()
Terminates PDFNet library.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int e_CNS1

The Constant e_CNS1.

Constant Value: 4 (0x00000004)

public static final int e_ConnectionErrorHandlingMode_continue

Constant Value: 0 (0x00000000)

public static final int e_ConnectionErrorHandlingMode_continue_unless_switching_to_demo

Constant Value: 1 (0x00000001)

public static final int e_ConnectionErrorHandlingMode_stop

Constant Value: 2 (0x00000002)

public static final int e_GB1

The Constant e_GB1.

Constant Value: 3 (0x00000003)

public static final int e_Identity

Standard character orderings. PDFNet.AddFontSubst() can be used to associate a specific font with a given character ordering and to override default font mapping algorithm.

Constant Value: 0 (0x00000000)

public static final int e_Japan1

The Constant e_Japan1.

Constant Value: 1 (0x00000001)

public static final int e_Japan2

The Constant e_Japan2.

Constant Value: 2 (0x00000002)

public static final int e_Korea1

The Constant e_Korea1.

Constant Value: 5 (0x00000005)

public static final int e_LogLevel_Debug

Constant Value: 0 (0x00000000)

public static final int e_LogLevel_Error

Constant Value: 4 (0x00000004)

public static final int e_LogLevel_Fatal

Constant Value: 5 (0x00000005)

public static final int e_LogLevel_Info

Constant Value: 2 (0x00000002)

public static final int e_LogLevel_Off

Constant Value: -1 (0xffffffff)

public static final int e_LogLevel_Trace

Constant Value: 1 (0x00000001)

public static final int e_LogLevel_Warning

Constant Value: 3 (0x00000003)

public static final int e_icm

The Constant e_icm.

Constant Value: 1 (0x00000001)

public static final int e_lcms

The Constant e_lcms.

Constant Value: 0 (0x00000000)

public static final int e_no_cms

The Constant e_no_cms.

Constant Value: 2 (0x00000002)

public static final int e_status_bad_Credentials

Constant Value: 3 (0x00000003)

public static final int e_status_err

Constant Value: 0 (0x00000000)

public static final int e_status_invalid_operation

Constant Value: 5 (0x00000005)

public static final int e_status_network_err

Constant Value: 2 (0x00000002)

public static final int e_status_ok

Constant Value: 1 (0x00000001)

public static final int e_status_service_down

Constant Value: 4 (0x00000004)

public static final int e_z_best_compression

Constant Value: 9 (0x00000009)

public static final int e_z_best_speed

Constant Value: 1 (0x00000001)

public static final int e_z_default_compression

Constant Value: -1 (0xffffffff)

public static final int e_z_no_compression

Constant Value: 0 (0x00000000)

Public Constructors

public PDFNet ()

Public Methods

public static boolean addFontSubst (int ordering, String fontpath)

Adds the font substitute

Parameters
ordering the ordering
fontpath path to font
Returns
  • true, if successful

public static boolean addFontSubst (String fontname, String fontpath)

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:

Parameters
fontname the fontname
fontpath path to font
Returns
  • true, if successful
Throws
PDFNetException 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... PDFNet.addFontSubst(PDFNet.e_Identity, "c:/myfonts/arialuni.ttf"); // Arial Unicode MS 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"); //...

public static void addPDFTronCustomHandler (int custom_id)

Add PDFTron Custom Security handler

Parameters
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.

public static void addResourceSearchPath (String path)

public static void enableJavaScript (boolean enable)

A switch that can be used to turn on/off JavaScript engine

Parameters
enable true to enable JavaScript engine, false to disable.

public static String getResourcesPath ()

Get the resources path.

Returns
  • the location of PDFNet resources folder. Empty string means that resources are located in your application folder.

public static String getSystemFontList ()

Get available fonts on the system.

Returns
  • A JSON list of fonts accessible to PDFNet

public static double getVersion ()

Get the version.

Returns
  • PDFNet version number.

public static String getVersionString ()

Returns
  • PDFNet version as a string.

public static void initialize (String license_key)

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

Parameters
license_key Optional license key used to activate the product. If the license_key is not specified, the product will work in demo mode. If the license_key is invalid, the function will throw an exception.

public static void initialize ()

Initializes PDFNet library. Initialize() is usually called once, during process initialization.

Note: With the exception of SetPersistentCache and SetTempPath, it is unsafe to call any other PDFNet API without first initializing the library

public static boolean isJavaScriptEnabled ()

Test whether JavaScript is enabled

Returns
  • true if it is enabled, false otherwise

public static void setColorManagement (int t)

Used to set a specific Color Management System (CMS) for use during color conversion operators, image rendering, etc.

Parameters
t identifies the type of color management to use.

public static void setConnectionErrorHandlingMode (int mode)

Sets the connection error handling behaviour for Apryse SDK The default for this method is e_continue

Parameters
mode Rules that Apryse SDK will follow after a connection error.

public static void setConnectionErrorProc (ConnectionErrorProc error_proc, Object data)

public static void setDefaultDeviceCMYKProfile (String icc_filename)

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.

Parameters
icc_filename the new default device CMYK profile

public static void setDefaultDeviceRGBProfile (String icc_filename)

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.

Parameters
icc_filename the new default device RGB profile

public static void setDefaultDiskCachingEnabled (boolean use_disk)

Sets the default policy on using temporary files.

Parameters
use_disk if parameter is true then new documents are allowed to create temporary files; otherwise all document contents will be stored in memory.

public static void setDefaultFlateCompressionLevel (int level)

Sets the default compression level for Flate (ZLib).

Parameters
level An integer in range 0-9 representing the compression value to use as a default for any Flate streams (e.g used to compress content streams, PNG images, etc). The library normally uses the default compression level (e_z_default_compression). For most images, compression values in the range 3-6 compress nearly as well as higher levels, and do so much faster. For on-line applications it may be desirable to have maximum speed e_z_best_speed = 1). You can also specify no compression (e_z_no_compression = 0). Default is e_z_default_compression (-1).

public static void setLogLevel (int level)

public static void setPersistentCachePath (String persistent_path)

Set the location of persistent cache files This method is provided for applications that require tight control of the location where temporary files are created.

Parameters
persistent_path path to persistent cache folder

public static boolean setResourcesPath (String path)

Set the location of PDFNet resource file.

Note: Starting with v.4.5 PDFNet does't require a separate resource file (pdfnet.res) on all desktop/server platfroms. As a result, this function is not longer required for proper PDFNet initialization. The function is still available on embedded systems and for backwards compatibility. The function can be also used to specify a deault search path for ICC profiles, fonts, and other user defined resources.

Parameters
path The default resource directory path.
Returns
  • true if path is found, false otherwise.

public static void setTempPath (String temp_path)

Set the location of temporary folder. This method is provided for applications that require tight control of the location where temporary files are created.

Parameters
temp_path path to temporary folder

public static void setViewerCache (int max_cache_size, boolean on_disk)

Sets the default parameters for the viewer cache. Any subsequently opened documents will use these parameters.

Note: Default Desktop - max_cache_size: 512 MB, on_disk = true. Default Mobile - max_cache_size: 100 MB, on_disk = false

Parameters
max_cache_size The maximum size, in bytes, of the entire document's page cache. Set to zero to disable the viewer cache.
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.

public static void setWriteAPIUsageLocally (boolean write_usage)

Enable writing API usage locally.

Parameters
write_usage if parameter is true API usage will be written to local JSON files in the persistent cache path otherwise no API usage is saved.

public static void terminate ()

Terminates PDFNet library. Terminate() is usually called once, when the process is terminated.

Note: it is unsafe to call any other PDFNet API after you terminate the library.