QX.js API Reference

app

app

The app represents the QuarkXPress application in java scripting world at global level. You can interact with the real application using its properties and methods.

Classes

APIError
Layout
PrintLayoutOptions
Project

Namespaces

constants
dialogs
undo

Methods

(static) activeBoxesDOM(layoutNode) → {NodeList}

Returns HTML DOM NodeList Object of the selected boxes. If layoutNode parameter is passed, NodeList of selected boxes from layoutNode is returned. If layoutNode is not specified, NodeList of all selected boxes is returned.
Parameters:
Name Type Description
layoutNode DOMNode Optional layout node.
Returns:
HTML DOM NodeList of selected boxes.
Type
NodeList

(static) activeLayout() → {app.Layout|app.APIError}

This function is used to get the active layout.
Returns:
Type
app.Layout | app.APIError

(static) activeLayoutDOM() → {NodeList}

Returns HTML DOM NodeList of all items in current layout.
Returns:
HTML DOM NodeList of all items in current layout.
Type
NodeList

(static) activeLayoutDOMWithStyleSheets() → {NodeList}

Returns HTML DOM NodeList of all items in current layout alongwith QXP resources.
Returns:
HTML DOM NodeList of all items in current layout alongwith QXP resources.
Type
NodeList

(static) activeProject() → {app.Project|app.APIError}

This function is used to get the reference of active project.
Returns:
Type
app.Project | app.APIError

(static) createProject(projectName, layoutName, layoutMediaType, printLayoutOptions) → {app.Project|app.APIError}

Creates the new project.
Parameters:
Name Type Description
projectName string Name to the new project (NULL, use default name).
layoutName string Name of the new layout.
layoutMediaType layoutMediaTypes See layoutMediaTypes for all available layout types.
printLayoutOptions app.PrintLayoutOptions
Returns:
Type
app.Project | app.APIError

(static) evalScript(code, url=opt, startLineopt, cbopt)

See:
  • eval() for all other scripts evaluation.
This function evaluates QuarkXPress JavaScript code represented as a string or URL.
Example
app.evalScript("app.createProject('myProjectName', 'myLayoutName'); return 'success');
app.evalScript("app.createProject('myProjectName', 'myLayoutName'), '', 0, (data)=>{console.log(data)});
Parameters:
Name Type Attributes Default Description
code string String of JavaScript code.
url= string <optional>
URL of javscript, considered only if code is empty.
startLine number <optional>
0 The is the base line number to use for error reporting.
cb scriptCompletedCallback <optional>
null Called after scrpit evaluation gets completed.

(static) getAppScriptsFolder() → {string}

This function is used to get the location of application defined scripts.
Returns:
The location of application defined javascript files.
Type
string

(static) getUserScriptsFolder() → {string}

This function is used to get the location of user defined scripts.
Returns:
The location of user defined javascript files.
Type
string

(static) importScript(path)

Use this function to import other javascript files, library or modules.
Example
app.importScript("https://code.jquery.com/jquery-3.3.1.min.js"); //This will import the jQuery library in current execution context.
app.importScript("C:/DATA/myLib.js"); //This will import the myLib.js in current execution context.
app.importScript("file:///C:/DATA/myLib.js"); //This will import the myLib.js in current execution context.
Parameters:
Name Type Description
path string Path of file.

(static) launchApp(path) → {number}

Opens the item specified by the path parameter. The item can be a file, folder or URI.
Example
app.launchApp("www.quark.com"); this will open the web resource in the default browser of the system
app.launchApp("C:/DATA"); this will open the file explorer.
Parameters:
Name Type Description
path string Path of file or folder.
Returns:
On Win: If the function succeeds, it returns a value greater than 32. If the function fails, it returns an error value that indicates the cause of the failure. On Mac: The status code returned by the open command.
Type
number

(static) openProject(path, flags) → {app.Project|app.APIError}

Opens a project file.
Parameters:
Name Type Description
path string Disk path of the project.
flags openProjectFlags See openProjectFlags for all available flags.
Returns:
Type
app.Project | app.APIError