Paged Docs
Scripting with paged.*
The Boa-based scripting layer — a sandboxed ECMAScript surface for reading and authoring a paged document through the paged.* host API. The full surface is generated from the engine catalog.
Reviewed against engine v0.51.1
In short Paged embeds a Boa ECMAScript engine and exposes a single
global, paged.*, for inspecting and editing the open document. The same
surface runs in the editor's script panel/REPL and headless via the paged-run
CLI. This reference is generated from the engine's own catalog, so it always
matches the running engine exactly.
How a script becomes pixels
Your script. Plain ECMAScript calling paged.* — no modules, no I/O.
The shape of a script
A script is plain ECMAScript (no modules, no I/O — see constraints).
It addresses elements by id, reads with paged.inspect / paged.get, and edits
with paged.set and the structural authoring functions. Every property write
returns a boolean so a script can branch on success.
Reads return JSON strings — parse them. paged.selection(), paged.tree(),
paged.stories() and every other read return a JSON string, not a live
value. Call JSON.parse(...) before you index into the result. The parsed
elements are { kind, id } objects; address one as the string `${kind}:${id}`
(e.g. textFrame:u3) when you pass it to paged.set / paged.inspect.
// Reads return JSON strings — parse them.
const [el] = JSON.parse(paged.selection());
if (el) {
const ref = `${el.kind}:${el.id}`; // e.g. "textFrame:u3"
paged.set(ref, "frameFillColor", "Color/Red"); // a real settable path
paged.set(ref, "frameRotationAngle", 12); // rotate 12°
}Try it
Edit the script and press Run: it executes in the real Paged editor on the stage, and the canvas updates live. Console output appears under the stage.
A first paged.* script — read the selection, then fill the frame red
What Run does
Run loads the Paged editor here, opens a page with one selected text frame and runs this script on it.
Look for The text frame on the page turns red and rotates 12°.
Console
Run the script to see its console output here.
The playground runs against play.paged.media. It needs that app deployed with the editable-script bridge and a cross-origin-isolated (COOP/COEP) page — both are wired here; see constraints for the sandbox model.
What's here
- Host functionsProIII· referenceevery
paged.*function, grouped by kind (read, write, author, history, console). - Settable pathsProIII· referencethe property
names you can pass to
paged.set, plus the id grammar for addressing elements. - ConstraintsProIII· referencethe sandbox rules and execution budgets.
| Form | Example | Meaning |
|---|---|---|
textFrame:<id> | textFrame:u123 | A text frame. Same scheme: rectangle:/oval:/polygon:/graphicLine:/group:. |
rectangle:<id> | rectangle:u12 | A rectangle (graphic frame). |
oval:<id> | oval:u13 | An oval. |
polygon:<id> | polygon:u14 | A polygon or open path. |
graphicLine:<id> | graphicLine:u15 | A graphic line. |
group:<id> | group:u88 | A group. paged.set("group:<id>", "groupTransform", [a,b,c,d,tx,ty]) moves it as a unit. |
frame:<id> | frame:u123 | Any page item, kind unknown (alias). paged.address / paged.query resolve it to the kind-specific form. |
storyRange:<storyId>@<start>..<end> | storyRange:Story/[email protected] | A character range within a story (half-open). storyId comes from paged.stories()[].selfId. Alias: story:<storyId>@<start>..<end>. |
doc | doc | The document itself. |
page:<id> | page:u1a2 | A body page, by its Self id (paged.pages()[].selfId), or page:#<n> for the n-th page (1-based). |
spread:<id> | spread:u1a1 | A spread, by its Self id. |
layer:<id> | layer:ub3 | A layer, by its Self id (paged.layers()). |
master:<id> | master:ua9 | A master spread. master:<id> > textFrame:<id> names an item on it. |
story:<id> | story:Story/u1 | A story, by its Self id. |
field:<storyId>@<offset> | field:Story/u1@12 | A text field anchored at a story character offset (paged.placeholders / RequestDocumentPlaceholders). |
table:<id> | table:u2f | A table, by its Self id (unique per document). |
cell:<tableId>/<row>,<col> | cell:u2f/0,1 | A table cell, zero-based row and column. |
style:<family>/<selfId> | style:paragraph/ParagraphStyle/Body | A style; family is paragraph | character | object | cell | table. The display name is accepted in place of the Self id. |
swatch:<id> | swatch:Color/Red | A colour or swatch, by its Self id. |
gradient:<id> | gradient:Gradient/u1 | A gradient, by its Self id. |
colorGroup:<id> | colorGroup:ColorGroup/u7 | A colour group. |
numberingList:<id> | numberingList:NumberingList/Steps | A numbering list. |
guide:<id> | guide:u5c | A ruler guide. |
condition:<id> | condition:Condition/Draft | A text condition. |
conditionSet:<id> | conditionSet:u3d | A condition set. |
section:<id> | section:u4e | A numbering section. |
hyperlink:<id> | hyperlink:u6a | A hyperlink. |
textVariable:<id> | textVariable:dTextVariablenFile Name | A text variable, by its Self id (the designmap's TextVariable). Its name is accepted in a selector: textVariable[name="Running Head"]. |
plugin:<pluginId>/<kind>/<id> | plugin:paged.image/layer/7 | An object a plugin owns. Opaque to core and carried through unchanged. |
$h:<name> | $h:newFrame | A batch handle bound earlier in the same batch. |
Filling a template
Fill a template in the editor's template-fill preset with its form and field outlines, preview it as an author, embed it, or fill it on a server.
Your first script
A hands-on, five-step introduction to the paged.* scripting API — read the document, address an element, write a property, author from scratch, and undo — each step runnable in a live editor.