The imposio object¶
The global entry point. It opens and creates documents and controls units.
Opening & creating documents¶
imposio.open(path, opts?)¶
Open a file from disk. By extension: PDF (directly), images (PNG/JPEG/BMP/GIF/TIFF/WebP →
one page), SVG, PostScript (PS/EPS, via Ghostscript), EPUB, or text/Markdown. Returns a
Document, or null (and throws) on failure.
| Parameter | Type | Description |
|---|---|---|
path |
string | Absolute path to the file. |
opts |
object | Import options (below); lengths in the current unit. |
Image opts: { size: [w, h] | dpi: N, bleed: { size, rgb: [r,g,b] (0–255) | cmyk:
[c,m,y,k] (0–100), backPage: true } } — size/dpi set the page size / print resolution;
bleed adds a solid-colour bleed frame (page grows by size on each edge, trim box = the
image, CMYK goes in as DeviceCMYK unconverted) and backPage: true appends a second page
filled with the same colour.
Text/EPUB opts: { pageSize: [w, h], margin, font, fontSize, wrap, encoding, markdown }.
var doc = imposio.open("/Users/me/jobs/booklet.pdf");
var card = imposio.open("card.png",
{ size: [90, 50], bleed: { size: 3, cmyk: [0, 100, 100, 0], backPage: true } });
imposio.newDocument(width, height)¶
Create a new, empty one-page document. Dimensions are in the current unit. Returns a Document.
| Parameter | Type | Description |
|---|---|---|
width |
number|string | Page width (current unit, or a string like "210mm"). |
height |
number|string | Page height. |
imposio.activeDocument()¶
Returns the currently active PDF tab in the GUI as a borrowed Document (changes affect the
live document; it is not deleted by the script). Returns null when running headless/CLI or
when no document is open.
imposio.activePage()¶
Returns the 0-based index of the page currently shown in the active tab, or -1 if none.
Units¶
imposio.setUnits(units)¶
Sets the unit for all subsequent length values and getters. Returns true; an unknown
unit throws.
| Value | Unit |
|---|---|
"mm" |
millimetres (default) |
"cm" |
centimetres |
"in" / "inch" |
inches |
"pt" / "point" |
PostScript points |
imposio.units()¶
Returns the current unit as a string.
Unit helpers¶
| Method | Returns |
|---|---|
imposio.toPt(v) |
v (current unit) → points |
imposio.fromPt(pt) |
points → current unit |
imposio.mmToPt(mm) |
millimetres → points (always mm) |
imposio.ptToMm(pt) |
points → millimetres (always mm) |
imposio.setUnits("in");
var pts = imposio.toPt(8.5); // 612
Data files¶
imposio.loadData(path, opts?)¶
Load a tabular file for variable data merging. Supports
CSV / TSV / TXT / XLSX / ODS / JSON. Returns { columns: […], rows: [[…]], format };
throws on error.
opts key |
Description | Default |
|---|---|---|
encoding |
e.g. "windows-1250" |
"Auto" |
firstRowHeaders |
First row holds the column names | true |
delimiter |
e.g. ";" (CSV) |
auto |
imposio.combineData(tables, opts?)¶
Combine several tables (from loadData or built in the script) into one
{ columns, rows }. tables is an array.
opts key |
Values | Meaning |
|---|---|---|
modes |
["append"\|"parallel", …] |
How tables[i] joins the result (modes[0] ignored): append = rows below, parallel = columns side by side. |
mismatch |
"pad" (default), "cycle", "truncate" |
Parallel tables with different row counts. |
Watermarks¶
imposio.readWatermarkImage(path, opts?)¶
Reads an Imposio watermark from a rendered or scanned image and returns
{ ok, text }. opts { seedX, seedY } are the pixel coordinates of a click on the
pattern (for a frame watermark, anywhere on the border) — this makes reading robust
even over busy artwork. See addWatermark for embedding.
var r = imposio.readWatermarkImage("scan.png", { seedX: 620, seedY: 18 });
if (r.ok) console.log("watermark:", r.text);