Namespace: PDFNet

PDFNet

Contains PDFNetJS classes and functions

Classes

Action
ActionParameter
AdvancedImagingModule
Annot
AnnotBorderStyle
AttrObj
Bookmark
ByteRange
CADModule
CaretAnnot
CharData
CheckBoxWidget
ChunkRenderer
CircleAnnot
ClassMap
ColorPt
ColorSpace
ComboBoxWidget
ContentItem
ContentReplacer
ConversionMonitor
Convert
Date
Destination
Destroyable
DictIterator
DigestAlgorithm
DigitalSignatureField
DisallowedChange
DocSnapshot
DocumentConversion
Element
ElementBuilder
ElementReader
ElementWriter
EmbeddedTimestampVerificationResult
FDFDoc
FDFField
Field
FileAttachmentAnnot
FileSpec
Filter
FilterReader
FilterWriter
Flattener
Font
FreeTextAnnot
Function
GeometryCollection
GState
HighlightAnnot
Highlights
HTML2PDF
Image
InkAnnot
Iterator
KeyStrokeActionResult
KeyStrokeEventData
LineAnnot
LinkAnnot
ListBoxWidget
MarkupAnnot
Matrix2D
MovieAnnot
NameTree
NumberTree
Obj
ObjectIdentifier
ObjSet
OCG
OCGConfig
OCGContext
OCMD
OCRModule
Optimizer
OwnedBitmap
Page
PageLabel
PageSet
PatternColor
PDF2HtmlReflowParagraphsModule
PDF2WordModule
PDFACompliance
PDFDC
PDFDCEX
PDFDoc
PDFDocInfo
PDFDocViewPrefs
PDFDraw
PDFRasterizer
PDFTronCustomSecurityHandler
PDFView
PDFViewCtrl
Point
PolygonAnnot
PolyLineAnnot
PopupAnnot
PrinterMode
PushButtonWidget
QuadPoint
RadioButtonGroup
RadioButtonWidget
Rect
Redaction
RedactionAnnot
Redactor
Reflow
ResultSnapshot
RoleMap
RubberStampAnnot
ScreenAnnot
SDFDoc
SecurityHandler
SElement
Separation
Shading
ShapedText
SignatureHandler
SignatureWidget
SoundAnnot
SquareAnnot
SquigglyAnnot
Stamper
STree
StrikeOutAnnot
StructuredOutputModule
TemplateDocument
TextAnnot
TextExtractor
TextExtractorLine
TextExtractorStyle
TextExtractorWord
TextMarkupAnnot
TextRange
TextSearch
TextWidget
TimestampingConfiguration
TimestampingResult
TrustVerificationResult
UnderlineAnnot
UndoManager
VerificationOptions
VerificationResult
ViewChangeCollection
WatermarkAnnot
WebFontDownloader
WidgetAnnot
X501AttributeTypeAndValue
X501DistinguishedName
X509Certificate
X509Extension

Members


<static> CharacterOrdering

Type:
  • number
Properties:
Name Type Description
e_Identity number
e_Japan1 number
e_Japan2 number
e_GB1 number
e_CNS1 number
e_Korea1 number

<static> CMSType

Type:
  • number
Properties:
Name Type Description
e_lcms number
e_icm number
e_no_cms number

<static> ConnectionErrorHandlingMode

Type:
  • number
Properties:
Name Type Description
e_continue number
e_continue_unless_switching_to_demo number
e_stop number

<static> LogLevel

Type:
  • number
Properties:
Name Type Description
e_LogLevel_Off number
e_LogLevel_Fatal number
e_LogLevel_Error number
e_LogLevel_Warning number
e_LogLevel_Info number
e_LogLevel_Trace number
e_LogLevel_Debug number

Methods


<static> addFontSubstFromName(fontname, fontpath)

addFontSubst functions can be used to create font substitutes that can override default PDFNet font selection algorithm. AddFontSubst 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. The following is an example of using this function 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");
... 
PDFDoc doc("c:/my.pdf");
...
Parameters:
Name Type Description
fontname string
fontpath string
Returns:
A promise that resolves to an object of type: "boolean"
Type
Promise.<boolean>

<static> addPDFTronCustomHandler(custom_id)

Parameters:
Name Type Description
custom_id number
Returns:
Type
Promise.<void>

<static> addResourceSearchPath(path)

Sets the location of PDFNet resource file. Note: Starting with v.4.5 PDFNet no longer requires a seperate resource file, and so this function is not required for proper PDFNet initialization. The function can be used on all platforms to specify search paths for ICC profiles, fonts, and other user defined resources.
Parameters:
Name Type Description
path string The resource directory path to add to the search list.
Returns:
Type
Promise.<void>

<static> beginOperation( [optionsObj])

beginOperation locks all Emscripten worker operations on PDFNet so as to avoid potential editing conflicts. Calling beginOperation a second time before finishOperation is called will result in an exception being thrown. This can be disabled allowing multiple beginOperations to be called by passing in an options object (a default javascript object {}) with its parameter "allowMultipleInstances" set to "true". Will do nothing for Node.js
Parameters:
Name Type Argument Default Description
optionsObj object <optional>
{}
Properties
Name Type Argument Default Description
allowMultipleInstances boolean <optional>
false If allowMultipleInstances set to true, multiple instances of beginOperation will be allowed.
Returns:
Type
Promise.<void>

<static> convertPageToAnnotAppearance(docWithAppearance, objNum, annot_state, appearance_state)

Parameters:
Name Type Description
docWithAppearance PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc
objNum number
annot_state number
PDFNet.Annot.State = {
	e_normal : 0
	e_rollover : 1
	e_down : 2
}
appearance_state string
Returns:
A promise that resolves to an unknown type

<static> deallocateAllObjects()

Removes all PDFNetJS objects from memory.
Returns:
Type
Promise.<void>

<static> displayAllocatedObjects()

Displays in the console a list of objects still in memory in the form of their type and ID.

<static> enableJavaScript(enable)

A switch that can be used to turn on/off JavaScript engine
Parameters:
Name Type Description
enable boolean true to enable JavaScript engine, false to disable.
Returns:
Type
Promise.<void>

<static> endDeallocateStack()

Deallocates all objects in memory that were created after the most recent startDeallocateStack call.
Returns:
Type
Promise.<void>

<static> finishOperation()

finishOperation releases the lock on all Emscripten worker operations on PDFNet. Will do nothing if PDFNet.beginOperation has not been called earlier. Will do nothing for Node.js
Returns:
Type
Promise.<void>

<static> getNormalizedUrl(url)

Parameters:
Name Type Description
url string
Returns:
A promise that resolves to an object of type: "string"
Type
Promise.<string>

<static> getStackCount()

Gets the number of PDFNet.startDeallocateStack() calls made that have not yet been ended.
Returns:
A promise that resolves to the number of PDFNet.startDeallocateStack() calls not yet ended.
Type
Promise.<number>

<static> getSystemFontList()

Get available fonts on the system.
Returns:
A promise that resolves to a JSON list of fonts accessible to PDFNet
Type
Promise.<string>

<static> getVersion()

Returns:
A promise that resolves to pDFNet version number.
Type
Promise.<number>

<static> getVersionString()

Returns:
A promise that resolves to an object of type: "string"
Type
Promise.<string>

<static> initialize( [licenseKey] [, options])

Initializes PDFNet library. Initialize() is usually called once, during initialization.
Parameters:
Name Type Argument Default Description
licenseKey string <optional>
License key used to activate the product.
options object <optional>
{} Options for PDFTron SDK.
Properties
Name Type Argument Description
writeAPIUsageLocally boolean <optional>
If set to true, API usage will be written to local JSON files in the persistent cache path.
persistentCachePath string <optional>
the location of persistent cache files.
Throws:
If the licenseKey is invalid, the function will throw an exception.
Returns:
Type
Promise.<void>

<static> isJavaScriptEnabled()

Test whether JavaScript is enabled
Returns:
A promise that resolves to true if it is enabled, false otherwise
Type
Promise.<boolean>

<static> runGeneratorWithCleanup(generator [, license_key])

This function is a utility method which will initialize PDFNet, begin a PDFNet operation execute an action defined by the first parameter generator and then finish this operation. This method will also clean up all PDFNet resources that are allocated within the generator which can greatly simplify user code. In some cases the user may wish to keep some PDFNet objects alive out of the scope of this generator function in which case takeOwnership should called on these objects. In case the user wishes to keep all the PDFNet objects alive, runGeneratorWithoutCleanup should be used instead.
Parameters:
Name Type Argument Description
generator object The generator object function to execute.
license_key string <optional>
the license key used to initialize PDFNet.
Returns:
a promise that resolves to the return value of the generator.
Type
Promise.<any>

<static> runGeneratorWithoutCleanup(generator [, license_key])

This function is a utility method which will initialize PDFNet and execute an action defined by the first parameter generator. Unlike runGeneratorWithCleanup this method will not clean up PDFNet resources which can be useful when the user wishes to keep all of the objects alive.
Parameters:
Name Type Argument Description
generator object The generator object function to execute.
license_key string <optional>
the license key used to initialize PDFNet.
Returns:
a promise that resolves to the return value of the generator.
Type
Promise.<any>

<static> runWithCleanup(callback [, licenseKey] [, options])

This function is a utility method which will initialize PDFNet, begin a PDFNet operation and run a callback function passed in. This method will also clean up all PDFNet resources that are allocated within the function which can greatly simplify user code. In some cases the user may wish to keep some PDFNet objects alive out of the scope of this function in which case takeOwnership should called on these objects. In case the user wishes to keep all the PDFNet objects alive, runWithoutCleanup should be used instead.
Parameters:
Name Type Argument Default Description
callback function A callback function to execute
licenseKey string <optional>
the license key used to initialize PDFNet.
options object <optional>
{} Options for PDFTron SDK.
Properties
Name Type Argument Description
writeAPIUsageLocally boolean <optional>
If set to true, API usage will be written to local JSON files in the persistent cache path.
persistentCachePath string <optional>
the location of persistent cache files.
Returns:
a promise that resolves to the return value (if there is one) of the input function
Type
Promise.<any>

<static> runWithoutCleanup(callback [, licenseKey] [, options])

This function is a utility method which will initialize PDFNet and execute an input. Unlike runWithCleanup this method will not clean up PDFNet resources which can be useful if the user wishes to keep all of the objects alive.
Parameters:
Name Type Argument Default Description
callback function A callback function to execute
licenseKey string <optional>
the license key used to initialize PDFNet.
options object <optional>
{} Options for PDFTron SDK.
Properties
Name Type Argument Description
writeAPIUsageLocally boolean <optional>
If set to true, API usage will be written to local JSON files in the persistent cache path.
persistentCachePath string <optional>
the location of persistent cache files.
Returns:
a promise that resolves to the return value (if there is one) of the input function
Type
Promise.<any>

<static> setColorManagement( [t])

used to set a specific Color Management System (CMS) for use during color conversion operators, image rendering, etc.
Parameters:
Name Type Argument Description
t number <optional>
PDFNet.CMSType = {
	e_lcms : 0
	e_icm : 1
	e_no_cms : 2
}
identifies the type of color management to use.
Returns:
Type
Promise.<void>

<static> setConnectionErrorHandlingMode(mode)

Sets the connection error handling behaviour for PDFTron SDK The default for this method is e_continue
Parameters:
Name Type Description
mode number
PDFNet.ConnectionErrorHandlingMode = {
	e_continue : 0
	e_continue_unless_switching_to_demo : 1
	e_stop : 2
}
Rules that PDFTron SDK will follow after a connection error.
Returns:
Type
Promise.<void>

<static> setConnectionErrorProc(error_proc, data)

Sets the error handling function to be called when an error is encountered when connecting to PDFTron Web Services.
Parameters:
Name Type Description
error_proc function Connection error handling callback function
data object Custom data to be passed as the fourth parameter to 'error_proc'.
Returns:
Type
Promise.<void>

<static> setDefaultDeviceCMYKProfileFromFilter(stream)

sets 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:
Name Type Description
stream PDFNet.Filter
Returns:
Type
Promise.<void>

<static> setDefaultDeviceRGBProfile(icc_filename)

sets 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:
Name Type Description
icc_filename string
Returns:
Type
Promise.<void>

<static> setDefaultDeviceRGBProfileFromFilter(stream)

sets 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:
Name Type Description
stream PDFNet.Filter
Returns:
Type
Promise.<void>

<static> setDefaultFlateCompressionLevel(level)

sets the default compression level for Flate (ZLib).
Parameters:
Name Type Description
level number 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 Value:
  • Z_DEFAULT_COMPRESSION (-1).
Returns:
Type
Promise.<void>

<static> setLogLevel( [level])

Parameters:
Name Type Argument Description
level number <optional>
PDFNet.LogLevel = {
	e_LogLevel_Off : -1
	e_LogLevel_Fatal : 5
	e_LogLevel_Error : 4
	e_LogLevel_Warning : 3
	e_LogLevel_Info : 2
	e_LogLevel_Trace : 1
	e_LogLevel_Debug : 0
}
Returns:
Type
Promise.<void>

<static> setResourcesPath(path)

Sets the location of PDFNet resource file. Note: Starting with v.4.5 PDFNet no longer requires a seperate resource file, and so this function is not required for proper PDFNet initialization. It remains available for backward compatibility. On mobile systems (iOS, Android, etc.) this method is required for proper initialization starting with version 6.0. (This helps reduce overall app size.) The function can be used on all platforms to specify a default search path for ICC profiles, fonts, and other user defined resources.
Parameters:
Name Type Description
path string The default resource directory path.
Returns:
A promise that resolves to true if path is found, false otherwise.
Type
Promise.<boolean>

<static> setViewerCache(max_cache_size, on_disk)

Sets the default parameters for the viewer cache. Any subsequently created documents will use these parameters.
Parameters:
Name Type Description
max_cache_size number The maximum size, in bytes, of the entire document's page cache. Set to zero to disable the viewer cache.
on_disk boolean If set to 'true', cache will be stored on the local filesystem. If set to 'false', cache will be stored in heap memory.
Default Value:
  • Desktop: max_cache_size = 512 MB, on_disk = true | Mobile: max_cache_size = 100 MB, on_disk = false
Returns:
Type
Promise.<void>

<static> shutdown()

This function shuts down the native backend. It will ensure the program can terminate when it is finished.
Returns:
Type
Promise.<void>

<static> startDeallocateStack()

startDeallocateStack initializes a deallocation point. All functions which create objects that take up memory after the most recent startDeallocateStack call will be deallocated upon calling PDFNet.endDeallocateStack().
Returns:
Type
Promise.<void>

<static> terminateEx(termination_level)

terminates PDFNet library. Terminate() is usually called once, when the process is terminated.
Parameters:
Name Type Description
termination_level number Optional termination level used to decide what operations need to be included Note: it is unsafe to call any other PDFNet API after you terminate the library.
Returns:
Type
Promise.<void>