Skip to content

Scripting API — overview

Imposio embeds a JavaScript engine (the Script tab). Scripts drive the same operations you perform by hand — open documents, impose, edit, export — so you can automate repetitive work and standardise output.

Running a script

Open the Script tab, write or open a .js file, and Run it. You can also record your actions in the GUI and Imposio writes the equivalent script (the snippets in these pages are the same calls the recorder produces).

The object model

Everything starts from a single global object, imposio:

imposio.setUnits("mm");
var doc = imposio.open("/path/to/file.pdf");   // → a Document
doc.setImposition({ /* … */ });
var out = doc.generateImposition();            // → a new Document
out.save("/path/to/out.pdf");
  • imposio — the entry point: open/create documents, units, helpers.
  • Document — a wrapper around one PDF: page operations, export, metadata, security, inspection.
  • ImpositionsetImposition() settings and generateImposition().
  • Edit layer — draw and manipulate vector shapes, text and images.
  • Examples — complete scripts.

Units

Lengths default to millimetres. Change the unit for all subsequent calls with imposio.setUnits() ("mm", "cm", "in", "pt").

Length values accept either a number (in the current unit) or a string with a suffix that overrides the unit:

imposio.setUnits("mm");
doc.addBlankPage(-1, 210, 297);     // mm
doc.addBlankPage(-1, "8.5in", "11in");  // explicit units per value

Coordinates

Geometry uses PDF coordinates: the origin is the bottom-left corner and Y points up. Page indexes are 0-based. Page ranges are strings: "all", "1-5", "odd", "even", "2,4,7" (empty string means all).

Error handling

Methods that fail throw a JavaScript exception (e.g. an invalid enum value, or a missing document). Wrap risky calls in try { … } catch (e) { … } if you need to handle failures gracefully. Methods that return a Document return null on failure.