Paged Docs / Command line (paged)
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.
Reviewed against engine v0.77.0
A batch: one finished file per record, or per group of records.
In short paged generate <template> --data <file> --out <dir> is the batch
verb of the Node command line (paged-node in a checkout, paged from
npm). paged.data's planBatch splits the records into
units — one per record, or one per group of records that share the --by
values — and each unit is a Data Merge of the template: merged, written to
--out, and undone, so the next unit starts from the template again. It is on
main and ships with the next release.
generate needs the paged.data module, whose
engine reads the records into its SQL store. The built-in modules are not
published on npm, so the npm paged reports that paged.data is not loaded; in a
checkout of paged-media/paged, build
the module's engine (moon run data:wasm) and run paged-node from
apps/cli with --plugins=@paged-media/data, as the
worked example
does for merge.
The template
The template is the one paged merge takes: a document whose text frames hold
<<field>> placeholders (the form InDesign's Data Merge uses), and optionally
image placeholder rectangles named with --image-field. Every option of
merge's layout applies to each unit.
Per record
paged-node generate card.idml --data products.csv --out cards \
--plugins=@paged-media/data{
"records": 3,
"per": "record",
"format": "paged",
"outputs": [
{ "path": "cards/card-1.paged", "unit": "row-0", "records": [0], "pages": 1, "overset": [], "bytes": 15012 },
{ "path": "cards/card-2.paged", "unit": "row-1", "records": [1], "pages": 1, "overset": [], "bytes": 15020 },
{ "path": "cards/card-3.paged", "unit": "row-2", "records": [2], "pages": 1, "overset": [], "bytes": 15004 }
]
}Files are named after the template and numbered from 1, zero-padded to the
width of the count (card-01 … card-12). records lists the 0-based records
each file holds; overset the records whose text did not fit.
Per group
--per group --by <fields> writes one document per distinct combination of the
--by values, holding every record of that group:
name,sku,price,cat
Widget,A-1,9.90,x
Gadget,B-2,19.99,y
Doohickey,C-3,1234.50,xpaged-node generate card.idml --data products.csv --per group --by cat \
--out by-category --format pdf --plugins=@paged-media/data,@paged-media/publishTwo files: the first (unit: "x") holds records [0, 2], the second
(unit: "y") record [1]. With --records-per-page multiple the records of a
group share pages; with the default single, each record gets its own page in
the group's document.
Options
| Option | Meaning |
|---|---|
--data <file> | The records: CSV, TSV, JSON, Parquet or XLSX, read by paged.data. Required. |
--out <dir> | The output directory. Required. |
--format <pdf|idml|paged> | The output format (default paged). |
--per <record|group> | One document per record (default), or per group. |
--by <a,b> | With --per group: the fields that make a group. --per group without it, or --by without --per group, is a usage error. |
--query <sql> | Select and order the records, in SQLite's dialect (default SELECT * FROM "data"). |
--records-per-page <single|multiple> | Data Merge's layout (default single). |
--arrange <rows|columns> | Multiple records: fill rows or columns first. |
--row-spacing <pt>, --column-spacing <pt> | Multiple records: the gaps. |
--remove-blank-lines | Drop lines whose only content is an empty field. |
--image-field <rectId=@field> | An image placeholder rectangle and the field holding its file (repeatable). |
--image-base <dir> | Where relative image paths resolve (default: the data file's directory). |
Plus the options every verb takes (--plugins, --font, --cmyk-profile, …).
PDF output
--format pdf writes each file through paged.publish's typed exportPdf when
that module is loaded — the PDF the editor's Export dialog makes — and through
the engine's own PDF door otherwise. The same holds for every verb that writes
a PDF: export, merge --format pdf, template fill -o x.pdf, package --pdf
and -o x.pdf on a write. export --core keeps the engine's door.
Failures
A run that would write nothing exits 1 and says why: a query that selects no
records, or a merge that placed no record (the template's first page holds no
<<field>> placeholder). A usage error exits 2.
Related
- paged.dataIntermediateII· explanationand its typed commands
—
planBatch,mergeand the rest, whichgeneratecalls. - Coming from Adobe InDesign ServerIntermediateII· how-toa template and a CSV to PDF/X-4, step by step.
- paged templateIntermediateII· referencefill a template's fields (not
<<field>>placeholders) from JSON. - On paged.media: the automation server.
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.
paged preflight and paged package
Check a document against the PDF exporter before output, and collect it with its links, fonts, a report and the lossless .paged into one folder or zip.