JavaScript Support
Prince supports most of ECMAScript 5th edition, but not strict mode. Later editions of ECMAScript are not supported.
The following table shows supported JavaScript objects, methods and properties. For more details, see also JavaScript in Prince.
* objects, methods and properties marked with an asterisk are Prince extensions.
Toggle (open/close) all properties
window
object
The global object
evalsource
function
Evaluates text as JavaScript source code.
- sourcestringCode to evaluate
Result of evaluation
parseIntvalue, radix
function
Turns input into an integer number.
- valuestring
- radixnumberIndicates number base, for example 10 to parse input as a decimal value, 16 for hex values.
number
parseInt('50')50
isNaN
function
Checks if the argument's value is the special Not a Number value.
boolean
isNaN(parseInt('hello'))true
escapestring
function
Computes a new string by replacing certain characters with a hexadecimal escape sequence.
- stringstringString to escape
string
unescapestring
function
Computes a new string by replacing hexadecimal escape sequences with the characters they represent.
- stringstringString to unescape
string
decodeURIComponentURI
function
Decodes a Uniform Resource Identifier (URI) component.
- URIstringA component of a URI
string
encodeURIComponentURI
function
Encodes a Uniform Resource Identifier (URI) component.
- URIstringA component of a URI
string
toLocaleString
function
Converts an object to a string with a language sensitive representation of said string.
string
hasOwnPropertyproperty
function
Returns a boolean indicating whether the object has the specified property.
- propertystringThe property to test
boolean
propertyIsEnumerable
function
Returns a Boolean indicating whether the specified property is enumerable.
boolean
Object
function
CSSStyleDeclaration
function
prototype
object
BoxInfo
function
The properties of a box, can be accessed after document conversion has finished - see <a href='/doc/javascript#the-box-tracking-api'>The Box Tracking API</a>.
Prince
object
See <a href='/doc/javascript#the-prince-object'>The Prince Object</a>.
addEventListenertype, callback, optional extra options
function
can be called to listen to the <code>complete</code> event on the Prince object. See <a href='/doc/javascript#event-handling'>Event Handling</a>.
- typestring
- callbackstring
- optional extra optionsstring
oncomplete
The <code>complete</code> event is fired when all layout is finished (and after the last repeated layout, if this was requested), just before the PDF is output, so that it can cancel the PDF output by triggering a fail-safe if necessary, or log information about the PDF like the page count.
addScriptFuncname, function
function
exposes an arbitrary JavaScript function to CSS. See <a href='/doc/gen-content#script-functions'>Script Functions</a>.
- namestring
- functionstring
trackBoxes
function
See <a href='/doc/javascript#the-box-tracking-api'>The Box Tracking API</a>.
- boolean
convertToFileJSON, OutputFileName, ...optional extra job resources
function
- JSONstringas specified in the <a href='/doc/server-integration#job-description-json'>Job description JSON</a>;
- OutputFileNamestring
- ...optional extra job resourcesArrayBuffers or strings
boolean, indicating success
convertToBufferJSON, ...optional extra job resources
function
- JSONstring
- ...optional extra job resourcesArrayBuffers or strings
ArrayBuffer if successful, null if not
pageCount
function
Total number of document pages, can be accessed after document conversion has finished.
registerPostLayoutFuncfunction
function
See <a href='/doc/javascript#multi-pass-formatting'>Multi-Pass formatting</a>.
- functionstring
PDF
object
See <a href='/doc/javascript#the-pdf-object'>The PDF Object</a>.
attachFileURL, description, filename, relationship
function
- URLstring
- descriptionstringOptional second argument to describe the attachment.
- filenamestringOptional third argument to specify the filename to be displayed for the attachment in the PDF.
- relationshipstringOptional fourth argument to specify the AFRelationship value of the attachment.
PDF.attachFile('data.xls', 'Latest sales figures.', 'SalesFigures', 'Data')
openAction
function
- stringNote that Prince passes the provided values verbatim to the PDF viewer, so the user can supply values that Prince doesn't know about, but the viewer does.
PDF.openAction('print')
Log
object
also available as <a href='#window.Prince.Log'><code>Prince.Log</code></a>.