Use of JavaScript runlists

To create an imposition configuration using JavaScript, start at the same place as for old-style imposition configurations. On the SwitchBoard, go to the "Arrange" group and then click on "Impose".

JavaScript runlists live in the same place as old-style runlists and you'll see all of them in the current library in the pull-down menu entitled "Imposition scheme" (1). Click on the arrow next to the options button (2) and you get a menu (3) with three choices:

  • New, to create a completely new runlist. This could be an old-style or JavaScript runlist.
  • Edit, to edit the currently selected runlist.
  • Duplicate, to create a copy of the currently created runlist and start editing it.

In all three cases, the runlist editor is opened.

Choosing the type of runlist

After opening the runlist editor, you can select the type of runlist using the radiobuttons at the top, just under the "Name" field.

Selecting "Runlist" adjusts the editor so you can write an old-style runlist using the proprietary tab-delimited format. Refer to existing documentation for more details about the runlist language.

Selecting "JavaScript" adjusts the editor so you can write a JavaScript runlist.

What pdfToolbox expects

When you select "JavaScript" you essentially get a generic JavaScript editor. This means you can:

  • Essentially write any JavaScript code you could in other JavaScript environments.
  • Access JavaScript objects supplied by pdfToolbox. Examples could be "app.doc" to access the document object for the document to be imposed and "app.vars" to access any variables pdfToolbox knows about at the time the imposition is done.

At the end of the runlist, pdfToolbox expects you to return a JavaScript object with a specific structure, containing sheet definitions, slots, and imposed sheets. This JavaScript object could be built from scratch by starting with a new JavaScript object and inserting the right properties and objects.

// Define imposition object with correct structure
const imposition = {
...
}

...

// "Return" to pdfToolbox
imposition;
Click to copy

Or it can be created by using the new "Impose" class and it's helper functions.

// Define imposition object using class
const imposition = new Impose();

...

// "Return" to pdfToolbox
imposition;
Click to copy

In general, using the Impose object and its convenience functions is the easiest way to accomplish the task.