Class PDFNet
PDFNet contains global library initialization, registration, configuration, and termination methods.
there is only a single, static instance of PDFNet class. Initialization and termination methods need to be called only once per application session.
Inherited Members
Namespace: pdftron
Assembly: PDFTronDotNet.dll
Syntax
public class PDFNet
Methods
AddFontSubst(string, string)
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:
Declaration
public static bool AddFontSubst(string fontname, string fontpath)
Parameters
Type | Name | Description |
---|---|---|
string | fontname | the fontname |
string | fontpath | the fontpath |
Returns
Type | Description |
---|---|
bool | true, if successful |
Examples
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");
//...
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
AddFontSubst(CharacterOrdering, string)
Adds the font subst.
Declaration
public static bool AddFontSubst(PDFNet.CharacterOrdering ordering, string fontpath)
Parameters
Type | Name | Description |
---|---|---|
PDFNet.CharacterOrdering | ordering | the ordering |
string | fontpath | the fontpath |
Returns
Type | Description |
---|---|
bool | true, if successful |
AddPDFTronCustomHandler(int)
Add PDFTron Custom Security Handler
Declaration
public static void AddPDFTronCustomHandler(int custom_id)
Parameters
Type | Name | Description |
---|---|---|
int | custom_id | The user's custom id. The id should match what was used to create PDFTronCustomSecurityHandler when encrypting the document. |
Remarks
Calling this function is a requirement to load files encrypted with PDFTronCustomSecurityHandler.
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
AddResourceSearchPath(string)
Adds a search location for PDFNet resource files.
Declaration
public static void AddResourceSearchPath(string val)
Parameters
Type | Name | Description |
---|---|---|
string | val |
|
Remarks
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. This function can be also used to specify search paths for ICC profiles, fonts, and other user defined resources.
EnableJavaScript(bool)
A swtich that can be used to turn on/off JavaScript engine
Declaration
public static void EnableJavaScript(bool enable)
Parameters
Type | Name | Description |
---|---|---|
bool | enable | true to enable JavaScript engine, false to disable. |
GetResourcesPath()
Declaration
public static string GetResourcesPath()
Returns
Type | Description |
---|---|
string | the location of PDFNet resources folder. Empty string means that resources are located in your application folder. |
GetVersion()
Gets the version.
Declaration
public static double GetVersion()
Returns
Type | Description |
---|---|
double | PDFNet version number. |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
GetVersionString()
Get PDFNet version as a string
Declaration
public static string GetVersionString()
Returns
Type | Description |
---|---|
string | PDFNet version as a string. |
Initialize()
Initializes PDFNet library.
Initialize()
is usually called once, during process initialization.
Declaration
public static void Initialize()
Remarks
With the exception of SetPersistentCache and SetTempPath, it is unsafe to call any other PDFNet API without first initializing the library
Initialize(string)
Initializes PDFNet library. Initialize() is usually called once, during process initialization.
Declaration
public static void Initialize(string license_key)
Parameters
Type | Name | Description |
---|---|---|
string | license_key | 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. |
Remarks
With the exception of SetPersistentCache and SetTempPath, it is unsafe to call any other PDFNet API without first initializing the library
IsJavaScriptEnabled()
Test whether JavaScript is enabled.
Declaration
public static bool IsJavaScriptEnabled()
Returns
Type | Description |
---|---|
bool | true, if it is enabled, false otherwise. |
SetColorManagement(CMSType)
Used to set a specific Color Management System (CMS) for use during color conversion operators, image rendering, etc.
Declaration
public static void SetColorManagement(PDFNet.CMSType cms)
Parameters
Type | Name | Description |
---|---|---|
PDFNet.CMSType | cms | identifies the type of color management to use. |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
SetConnectionErrorHandlingMode(ConnectionErrorHandlingMode)
Sets the connection error handling behaviour for Apryse SDK. The default for this method is e_continue
Declaration
public static void SetConnectionErrorHandlingMode(PDFNet.ConnectionErrorHandlingMode mode)
Parameters
Type | Name | Description |
---|---|---|
PDFNet.ConnectionErrorHandlingMode | mode | Rules that Apryse SDK will follow after a connection error. |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
SetConnectionErrorProc(ConnectionErrorProc, object)
Sets the error handling function to be called when an error is encountered when connecting to PDFTron Web Services.
Declaration
public static void SetConnectionErrorProc(PDFNet.ConnectionErrorProc error_proc, object data)
Parameters
Type | Name | Description |
---|---|---|
PDFNet.ConnectionErrorProc | error_proc | Connection error handling callback function (or delegate in .NET) |
object | data |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
SetDefaultDeviceCMYKProfile(string)
Sets the default ICC color profile for DeviceCMYK color space.
Declaration
public static void SetDefaultDeviceCMYKProfile(string icc_filename)
Parameters
Type | Name | Description |
---|---|---|
string | icc_filename | the new default device cmyk profile |
Remarks
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.
SetDefaultDeviceRGBProfile(string)
Sets the default ICC color profile for DeviceRGB color space.
Declaration
public static void SetDefaultDeviceRGBProfile(string icc_filename)
Parameters
Type | Name | Description |
---|---|---|
string | icc_filename | the new default device rgb profile |
Remarks
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.
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the pDF net exception |
SetDefaultDiskCachingEnabled(bool)
Sets the default policy on using temporary files.
Declaration
public static void SetDefaultDiskCachingEnabled(bool use_disk)
Parameters
Type | Name | Description |
---|---|---|
bool | use_disk | if parameter is true then new documents are allowed to create temporary files; otherwise all document contents will be stored in memory. |
SetDefaultFlateCompressionLevel(int)
Sets the default policy on using temporary files.
Declaration
public static void SetDefaultFlateCompressionLevel(int level)
Parameters
Type | Name | Description |
---|---|---|
int | 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 (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 Z_BEST_SPEED = 1). You can also specify no compression (Z_NO_COMPRESSION = 0). Default is Z_DEFAULT_COMPRESSION (-1). |
SetPersistentCachePath(string)
Set the location of persistent cache files.
Declaration
public static void SetPersistentCachePath(string path)
Parameters
Type | Name | Description |
---|---|---|
string | path | path to persistent cache folder |
Remarks
This method is provided for applications that require tight control of the location where temporary files are created.
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
SetResourcesPath(string)
Sets the location of PDFNet resource file.
Declaration
public static bool SetResourcesPath(string path)
Parameters
Type | Name | Description |
---|---|---|
string | path |
|
Returns
Type | Description |
---|---|
bool | true if path is found, false otherwise. |
Remarks
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.
SetTempPath(string)
Set the location of temporary folder.
Declaration
public static void SetTempPath(string path)
Parameters
Type | Name | Description |
---|---|---|
string | path | the temp_path |
Remarks
This method is provided for applications that require tight control of the location where temporary files are created.
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
SetViewerCache(uint, bool)
Sets the default parameters for the viewer cache. Any subsequently opened documents will use these parameters.
Declaration
public static void SetViewerCache(uint max_cache_size, bool on_disk)
Parameters
Type | Name | Description |
---|---|---|
uint | max_cache_size | The maximum size, in bytes, of the entire document's page cache. Set to zero to disable the viewer cache. |
bool | 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. |
Remarks
Default on Desktop - max_cache_size: 512 MB on_disk: true on Mobile - max_cache_size: 100 MB on_disk: false
SetWriteAPIUsageLocally(bool)
Enable writing API usage locally.
Declaration
public static void SetWriteAPIUsageLocally(bool write_usage)
Parameters
Type | Name | Description |
---|---|---|
bool | 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. |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
Terminate()
Dummy method
Declaration
public static void Terminate()