Paged Docs
Templates
A paged template is an ordinary .paged or IDML document whose x-paged:template labels say which parts are fields and what a filler may change. The engine enforces it.
Reviewed against engine v0.74.2
A template is a document that knows which parts are open.
In short A template is an ordinary .paged or .idml document. Its
policy lives in labels with the key x-paged:template: one on the document
(what a filler may do everywhere, the order of the form) and one on each item
that is a field or has its own permissions. A session has a role; a
filler may change only what the policy permits, and the engine — not the UI —
refuses everything else, from any caller. Fill a template in the editor's
template-fill preset, through the embedding handle,
or on a server with paged template.
How a template is stored
| Where | Label | Holds |
|---|---|---|
| the document (designmap) | x-paged:template | permissions a filler has on every item (none by default), the form order, text-variable fields |
| a page item | x-paged:template | the item's field definition, and permissions granted or denied on it |
Both values use the envelope every x-paged: label uses, { "v": 1, "data": … }.
An item's policy:
{
"v": 1,
"data": {
"field": {
"name": "headline",
"kind": "text",
"label": "Headline",
"required": true,
"constraints": { "maxLength": 30 }
},
"allow": ["text.style"],
"deny": []
}
}Because the policy is document data in labels, it travels wherever labels do:
.paged save and load, and IDML export and import. A label that cannot be read
does not stop the document from opening: that item (or the document) then has no
policy, which for a filler means nothing is permitted there.
The parts
- FieldsIntermediateII· referencethe open parts: kinds, constraints, values, which kinds can be set today, and the module fields every built-in module contributes (a sheet's cell, a doc's paragraph, a drawing's colour).
- Permissions and rolesProIII· referencethe permission vocabulary, how a filler's permissions are resolved, the three doors the engine checks, and the typed refusals.
- Filling a templateIntermediateII· how-tothe form and field
outlines in the editor, the
template-fillandviewerpresets, and filling on a server.
Making a template
An author makes a template in the editor's Template panel (paged.template):
- Take up authoring. Only the
authorrole may write the policy; the panel offers to switch the session to it ("Author template") and back ("Stop authoring"). - Make a field. Select one item and choose its kind — text, image,
visibility, or module content (one of the field kinds the loaded modules
offer, with the module's definition as JSON) — and give it a name, a label,
a group, help text,
required, and for text a maximum length. Saving writes the item'sx-paged:templatelabel and gives the item the field's name, so the field can be addressed by name and the name survives an InDesign round trip. Remove field takes it off again. - Grant more on the item, beyond what the field takes: format the text, move and scale the picture in its frame, move, resize, rotate, delete, show or hide, change the fill or the stroke.
- Set what a filler may do everywhere (the document's defaults): select any item, add and remove pages, add new items. Nothing is permitted by default.
- Preview as filler. The session switches to the
fillerrole and the template behaves as a filler will see it: the form, the outlines, and the engine's refusals. Back to authoring switches back; the undo history stays, so an author's edit made before the preview can still be undone.
The panel lists the template's fields with their labels and kinds; a refused
write shows under the field editor in words. Every change is one label write the engine checks like any other; a policy can also be
written without the panel, through the setPluginMetadata mutation in an author
session (for example through the
embedding handle's client).
InDesign
- Names. A field is addressed by its name. Give the item the same name in
InDesign's Layers panel and the field can be addressed by it from outside
(
frame[name="headline"]); a name survives an InDesign save where an internal id may not. - Labels. The policy is stored in IDML item labels, which paged writes on export and reads on import.
- XML tags. Many InDesign template workflows mark the editable parts of a
layout with XML tags. File ▸ Open as template… reads them: a tagged text
frame or story becomes a text field (on the first frame of its thread), a
tagged rectangle, oval or polygon an image field, and a tagged range of text a
field for that text in its story. The field takes the tag's name (
-2,-3for repeats), and the tag'slabel,maxLengthandrequiredattributes become its label and constraints. The dialog lists every field it would make, each with a checkbox, and every tag it skips with the reason ("it is on a parent page", "a line or a group is no kind of field", …); on a document that already has fields it marks each as new, already a field, or changed, and lists the fields no tag names any more. Applying is one undo step. - Writing tags. Make field tags a text or image field's item with a tag
named after the field (with its
label,maxLengthandrequiredas attributes), and Remove field untags it. paged writes XML tags on IDML export once the structure was edited, so the tags travel back to InDesign; an unchanged import still exports byte for byte. A tagged range is not yet enforced on its own — its field grants editing of its whole story — and templates made in paged have not yet been checked by opening them in InDesign. - On a server.
paged template ingest <doc> -o <out>(the Node command line) does the same as Open as template:--namesmakes untagged items with a name fields too, and--placeholdersturns plugin placeholders (Data Merge fields) into fields.
Template preflight
The Template panel's Problems section, shown to an author, lists what would break the template before it reaches a filler, and the field outlines mark the fields concerned:
| Code | Severity | Found when |
|---|---|---|
policyUnreadable | error | A template label cannot be read. |
fieldUnnamed | error | A field has no name, so no form or data can address it. |
fieldDuplicate | error | Several fields share a name; a value would reach only one. |
imageNotReplaceable | error | A picture field sits on an item that holds no picture. |
textHasNoStory | error | A text field sits on an item that holds no text. |
requiredHidden | warning | A required field's item is hidden. |
fieldOnParentPage | warning | A field is on a parent page, where no filler reaches it. |
linkMissing | warning | A picture field shows a picture that is not in the package. |
The findings are the engine's templateFindings collection. They are not the
PDF exporter's checks, which paged preflight
runs.
Catalogues
A template's own text, picture and visibility fields can be bound to data with
paged.data: in the Bindings panel's Template
fields section, bind each field to an expression over a query, choose one page
per record or one page per group, and Make catalogue. The template page is
repeated once per record or group and each copy filled, checked against the
fields' required and maxLength (one refused value refuses the whole run);
running it again replaces the copies. Scripts and the command line reach it
through paged.data's typed commands (templateFieldTargets,
bindTemplateField, runCatalogue).
The Template panel's This page section lets a filler copy the page and remove its copies — the pages of a catalogue — and nothing else; an author makes the first catalogue. Choice, text-run, data and module fields are not catalogue targets, and a page whose stories hold a table, an anchored object or a footnote cannot be repeated yet.
Related
- On paged.media: Paged for designers.
Languages
Run the embedded paged editor in the host's language — English and German ship, a host can supply its own catalogue, and extensions translate through host.strings.
Template fields
The open parts of a template — the engine's field kinds, the module field kinds of every built-in module, constraints, values, and what can be set today.