@zebrash/node
v1.0.3
Published
Render ZPL labels to PNG or SVG on Node.js and Bun. Pure TypeScript port of ingridhq/zebrash.
Maintainers
Readme
@zebrash/node
Render ZPL II labels
to PNG or SVG on Node.js and Bun. Pure-TypeScript port of
ingridhq/zebrash. Rasterizes via
@napi-rs/canvas (Skia) — no system
Cairo, no native build step. A free, local alternative to
labelary.com/viewer.html.
Install
npm install @zebrash/node@napi-rs/canvas ships prebuilt Skia binaries for macOS, Linux, and Windows on
both x64 and arm64.
Usage
import { readFile, writeFile } from "node:fs/promises";
import { Parser, Drawer } from "@zebrash/node";
const zpl = await readFile("./label.zpl");
const labels = new Parser().parse(zpl);
const png = await new Drawer().drawLabelAsPng(labels[0], {
labelWidthMm: 101.6, // 4 in
labelHeightMm: 203.2, // 8 in
dpmm: 8, // 203 dpi
});
await writeFile("./label.png", png);A single ^XA…^XZ block produces one LabelInfo. Multi-label ZPL with
^DF/^XF template recall produces several — iterate the array.
SVG output
const svg = await new Drawer().drawLabelAsSvg(labels[0], {
labelWidthMm: 101.6,
labelHeightMm: 203.2,
dpmm: 8,
fontEmbed: "url", // "url" | "embed" | "none"
});Returns a Promise<string>. Real <rect> per barcode module, real <text>
per ^FD field. Only ^GF bitmaps fall back to embedded raster.
Browser?
Use @zebrash/browser — same
API, OffscreenCanvas instead of Skia, zero native deps.
Documentation
Full docs, supported ZPL command surface, and the DrawerOptions reference
live in the main README.
License
MIT.
