Show / Hide Table of Contents

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.

Inheritance
System.Object
PDFNet
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ToString()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: pdftron
Assembly: PDFNetiOS.dll
Syntax
public class PDFNet

Methods

AddFontSubst(PDFNet.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

System.String fontpath

the fontpath

Returns
Type Description
System.Boolean

true, if successful

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
System.String fontname

the fontname

System.String fontpath

the fontpath

Returns
Type Description
System.Boolean

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

AddPDFTronCustomHandler(Int32)

Add PDFTron Custom Security Handler

Declaration
public static void AddPDFTronCustomHandler(int custom_id)
Parameters
Type Name Description
System.Int32 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
System.String val
  • The resource directory path to add to the searched list.
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(Boolean)

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

Declaration
public static void EnableJavaScript(bool enable)
Parameters
Type Name Description
System.Boolean enable

true to enable JavaScript engine, false to disable.

GetResourcesPath()

Declaration
public static string GetResourcesPath()
Returns
Type Description
System.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
System.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
System.String

PDFNet version as a string.

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
System.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
System.Boolean

true, if it is enabled, false otherwise.

SetColorManagement(PDFNet.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(PDFNet.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(PDFNet.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)

System.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
System.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
System.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(Boolean)

Sets the default policy on using temporary files.

Declaration
public static void SetDefaultDiskCachingEnabled(bool use_disk)
Parameters
Type Name Description
System.Boolean 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(Int32)

Sets the default policy on using temporary files.

Declaration
public static void SetDefaultFlateCompressionLevel(int level)
Parameters
Type Name Description
System.Int32 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
System.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
System.String path
  • The default resource directory path.
Returns
Type Description
System.Boolean

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
System.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(UInt32, Boolean)

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
System.UInt32 max_cache_size

The maximum size, in bytes, of the entire document's page cache. Set to zero to disable the viewer cache.

System.Boolean 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(Boolean)

Enable writing API usage locally.

Declaration
public static void SetWriteAPIUsageLocally(bool write_usage)
Parameters
Type Name Description
System.Boolean 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

In This Article
Back to top Generated by DocFX