Paged Docs / Command line (paged)
paged template
The npm paged command lists a template's fields and module field kinds, fills them to .paged, .idml or PDF, checks a submission, and makes a template from XML tags.
Reviewed against engine v0.74.2
Fill and check templates on a server, with the engine the browser uses.
In short paged template is a verb of the paged command from
npm (@paged-media/paged). It sends the same engine
messages as the editor's template form, in a filler session, so a value the
template does not permit is refused here as it is in the
browser. It is on main and ships with the next @paged-media/paged release. The Rust command line, whose reference is
generated from its own parser, does not have it yet; its engine-serve fills a
template's engine fields inside an HTTP call
(Filling a template).
Module fields — a sheet's cell, a
doc's paragraph, an image's picture — are read and written by the module that
owns their kind, after the session takes the filler role, so the engine checks
the module's writes too. That needs the module's bundle loaded: the command
loads the built-in module bundles it can resolve from the directory it runs in,
and any installed dependency that declares a paged manifest (--plugins a,b
names them; see the paged command). The built-in
module bundles are not published on npm; in a checkout of
paged-media/paged they are workspace
packages, and --plugins names a module's bundle by path, its wasm built (as the
command's own tests do). A module field whose module is not loaded is reported,
not skipped.
Output is JSON; --text prints it for humans. Exit codes: 0 success, 1
refused or failed, 2 usage.
paged template fields <doc>
Lists the template's fields in form order, each with its definition (name, kind, label, constraints), its target, and its current value.
npx @paged-media/paged template fields card.paged
npx @paged-media/paged template fields card.idml --textheadline text {"kind":"text","text":"Your headline"}
photo image {"kind":"image","uri":"https://example.com/placeholder.jpg"}
showBadge visibility {"kind":"visible","visible":true}
price module {"kind":"module","value":"12.50"}A module field's value comes from its module ({"kind":"module","value":…}),
or is null when its module is not loaded.
paged template kinds
Lists the module field kinds the loaded modules offer: each kind's id, the form control it declares (text, number, choice, toggle, picture, table) and its title.
npx @paged-media/paged template kinds --textmedia.paged.sheet.cell text Sheet cell
media.paged.sheet.range table Sheet range
media.paged.sheet.chartSource choice Chart datapaged template fill <template> --values <json|file> -o <out>
Sets the session to filler, fills the fields, and writes the result. The
output format follows the extension of -o: .paged, .idml or .pdf.
| Option | Meaning |
|---|---|
--values <json|file> | The values, inline JSON or a file holding it. Required. |
-o, --out <file> | Where to write the result. Required. |
--values takes either form:
[
{ "name": "headline", "value": { "kind": "text", "text": "Grand opening" } },
{ "name": "photo", "value": { "kind": "image", "uri": "https://example.com/shop.jpg" } }
]{ "headline": "Grand opening", "showBadge": true }In the object form a string is a text value, a boolean a visibility value, and anything else is taken as a full value object.
A module field takes its module's value as plain JSON: a string for a text or a
choice, a number, a boolean for a toggle, a list of rows for a table. A picture
is a file on disk, { "$file": "<path>" }, relative to the working directory:
{
"headline": "Grand opening",
"price": "12.50",
"prices": [["Espresso", "2.40"], ["Cappuccino", "3.20"]],
"hero": { "$file": "photos/shop.jpg" }
}Engine values are set first, as one batch; module values follow in the template's field order, whatever order they are given in.
npx @paged-media/paged template fill card.paged \
--values values.json -o card.pdfIf any engine value does not fit its field (required, maxLength, the kind),
nothing is written and the command exits 1 with the problems. A module value
its module refuses is reported the same way, with the module's sentence, and
nothing is written. If the template does not permit a write, it exits 1
with the refusal (not permitted: <permission> on <target>, or a locked item).
Which kinds can be set today: Template fields.
paged template check <template> <filled>
Answers "is <filled> the template with only its fields changed?". It reads
the field values from the filled document, fills a fresh copy of the template
with them in a filler session, and compares the two documents object by object —
page items, stories and pages, and the loaded modules' objects (a sheet's
cells, a doc's blocks), every readable property including story content. Rows a
module derives from the session rather than stores in the document (a query's
record count) are left out. The template, not the submission, is the authority.
npx @paged-media/paged template check card.paged submitted.paged- Exit
0:ok: only the template's fields differ. - Exit
1: changed outside the template's fields, with the address of every object that differs (differencesin the JSON).
paged template ingest <doc> -o <out>
Makes a template out of a document's XML tags, as the editor's
File ▸ Open as template… does: it takes the author role, derives the fields
from the tags (a tagged text frame or story a text field, a tagged rectangle,
oval or polygon an image field, a tagged text range a field for that text),
writes them and saves to -o.
npx @paged-media/paged template ingest tagged.idml -o card.paged --textwrote card.paged
headline text
photo image
skipped footer: it is on a parent page| Option | Meaning |
|---|---|
-o, --out <file> | Where to write the template. Required. |
--names | Untagged items with a name become fields too. |
--placeholders | Plugin placeholders (Data Merge fields) become fields too. |
The JSON output carries fields and skipped (each skipped tag with its
reason). If nothing becomes a field, the command fails with "nothing in the
document is a field". The Rust paged template has fields, fill and
check, not ingest. See Templates ▸ InDesign.
Related
- On paged.media: the automation server.
The paged command from npm
The `paged` command and its `paged mcp` server, installed from npm as @paged-media/paged — no Rust toolchain, Node 22 or later, or Bun.
paged generate
One document per record or per group of records — a Data Merge template and a data file turned into a folder of .paged, .idml or PDF files from the command line.