Step by step - Learn how to use callas productscallas pdfToolbox Variables and JavaScriptVariables using JavaScript: pdfToolbox objects and methods

Variables using JavaScript: pdfToolbox objects and methods

This article provides an overview of all JavaScript objects and methods that are specific to pdfToolbox Variables. It is the same information that can be displayed in the Script editor of pdfToolbox.

app Returns the global application object.

app.requires(key)Defines a variable key with default value 0 that is required by the current script.
Example:
app.requires("myvar")

app.requires(key,value)Defines a variable key and its default value that is required by the current script.
(Please see the note at the end of the list for the interpretation of the values.)
Example:
app.requires("myvar",10)

app.requires(key,value,label)Defines a variable key and its default value and a display name (label) that is required by the current script.
(Please see the note at the end of the list for the interpretation of the values.)
Example:
app.requires("myvar",10,"Input value for myvar")

app.nameReturns the application name.

app.versionReturns the application version string.

app.varsReturns the var objects containing all variables defined in the current context.

app.vars.varkeyReturns the value of the variable "varkey" if that exists in app.vars.
Example:
app.vars.varname

app.docRetuns the doc object for the current PDF document or 'undefined' if no PDF is open.

app.doc.infoReturns the docinfo object containing all document info entries of the current PDF document.

app.doc.pathReturns the full platform dependent file path of the current pdf document.

app.doc.documentFileNameReturns the file name of the current PDF document.

app.doc.numPagesReturns the number of pages of the current PDF document.

app.doc.getPageBox()Returns an array containing the left, top, right and bottom coordinates of the TrimBox of the first page in pt.

app.doc.getPageBox(pageBox)Returns an array containing the left, top, right and bottom coordinates of the specified page box of the first page in pt. 'pageBox' must be one of "Art", "Bleed", "Crop", "Trim" and Media.
Example:
app.doc.getPageBox(Trim)

app.doc.getPageBox(pageBox,pageNumber)Returns an array containing the left, top, right and bottom coordinates of the specified page box of the specified page in pt. 'pageBox' must be one of Art, Bleed, Crop, Trim and Media.
Example:
app.doc.getPageBox(Trim,0)

app.doc.getPageBox(pageBox,pageNumber,precision)Returns an array containing the left, top, right and bottom coordinates of the specified page box of the specified page with the given precision in pt. 'pageBox' must be one of Art, Bleed, Crop, Trim and Media.
Example:
app.doc.getPageBox(Trim,0,2)

app.doc.getPageRotation()Returns the page rotation of the first page.

app.doc.getPageRotation(pageNumber)Returns the page rotation of the specified page.
Example:
app.doc.getPageRotation(0)

app.doc.pagesReturns an array with page objects for the current PDF document.

app.doc.pages[i].inksReturns an array of inks used by on the page.
Example:
app.doc.pages[0].inks

app.doc.pages[i].inks[j].nameReturns the name of the ink.
Example:
app.doc.pages[0].inks[0].name

app.doc.pages[i].getPageBox()Returns an array containing the left, top, right and bottom coordinates of the TrimBox of the specified page box in pt.
Example:
app.doc.pages[0].getPageBox()

app.doc.pages[i].getPageBox(pageBox)Returns an array containing the left, top, right and bottom coordinates of the specified page box in pt. 'pageBox' must be one of Art, Bleed, Crop, Trim and Media.
Example:
app.doc.pages[0].getPageBox(Trim)

app.doc.pages[i].getPageBox(pageBox,precision)Returns an array containing the left, top, right and bottom coordinates of the specified page box with the given precision in pt. 'pageBox' must be one of Art, Bleed, Crop, Trim and Media.
Example:
app.doc.pages[0].getPageBox(Trim,2)

app.doc.pages[i].getPageRotation()Returns the page rotation of the page.

app.doc.xmpReturns a XMP object for the document XMP metadata of the current PDF document.

app.doc.xmp.getProperty(ns,property)Returns the value of the specified property in the specified namespace or 'undefined' if the property does not exists. 'ns' must be the full namespace uri. For namespaces defined in the XMP spec the predfeined namespace prefix can be used as well.
Examples:
app.doc.xmp.getProperty(http://purl.org/dc/elements/1.1/,format)
app.doc.xmp.getProperty(dc,format)

app.doc.metadataReturns the document XMP metada as plain XML

app.doc.resultReturns a preflight result object or 'undefined' if no preflight result is available. A preflight result is only available inside process plans if a profile or check was executed in a previous step.

app.doc.result.hitsReturns information about a previous preflight result.

app.doc.result.hits.numErrorsReturns the number of errors of a prvious preflight result.

app.doc.result.hits.numWarningsReturns the number of warnings of a prvious preflight result.

app.doc.result.hits.numInfosReturns the number of info hits of a prvious preflight result.

app.doc.result.checksReturns an array of Check objects for the previous preflight result.

app.doc.result.checks.lengthReturns the lenght of the array of Check objects for the previous preflight result.

app.doc.result.checks[i].idReturns the check ID of the specified check for the previous preflight result.
Example:
app.doc.result.checks[0].id

app.doc.result.checks[i].nameReturns the display name of the specified check of the previous preflight result.
Example:
app.doc.result.checks[0].name

app.doc.result.checks[i].severityReturns the severity of the specified check for the previous preflight result: 1: Info, 2: Warning, 3: Error.
Example:
app.doc.result.checks[0].severity

app.doc.result.checks[i].numHitsReturns the number of hits of the specified check for the previous preflight result.
Example:
app.doc.result.checks[0].numHits

app.doc.result.checks[i].pageNumbersReturns an array of page numbers (starting with 0) for pages that had hits with the specified check for the previous preflight result.
Example:
app.doc.result.checks[0].pageNumbers

Interpretation of the app.requires values

In version 10.0, the recognition for input types has been improved.
Depending on the kind of default value, the value is recognized as String, Number or Boolean.

Examples:

app.requires("type", true)

will be handled as Boolean and therefore shows a checkbox in the ask-at-runtime dialog in the user interface.

app.requires("type", "true")   or   app.requires("type", "1")
 will be recognized as String and therefore a text input field is shown in the user interface.

app.requires("type", 1)

will be handled as Numbers with an input field in the user interface, which is restricted to numerical values.

0 Comments

Send Your Comment

E-Mail me when someone replies to this comment