A pure-JS, zero-browser layout VM for deterministic typesetting and bit-perfect PDFs. Stop wrestling with bloated headless Chrome. VMPrint natively handles multilingual shaping, complex contextual pagination, and multi-page layout in under 30ms—all driven by an 88 KiB kernel.
VMPrint: Deterministic Typesetting for the Programmable Web
Stop using headless Chrome to print text.
Inspired by the legacy of Display PostScript, VMPrint is a deterministic, pure-JS typesetting and layout VM designed to provide bit-perfect output across any context such as PDF, Canvas and SVG. It abandons the DOM entirely, relying instead on pure font-metric mathematics rather than a web browser's best guess.
Operating natively across diverse environments—from Cloudflare Workers to standard web browsers—VMPrint bypasses the 170 MB bloat, memory leaks, and slow cold-starts associated with headless browser pipelines. It ensures absolute mathematical precision in document layout, producing identical, reproducible outputs regardless of the runtime context via a unique JSON instruction stream.
Key Features Zero-Browser Footprint: The core engine operates independently of Node.js APIs or the DOM, packing down to just 88 KiB.
Deterministic Layout: Developed with a versioned JSON instruction schema, guaranteeing that the exact same input always yields the exact same sub-point glyph positioning across machines.
True Multilingual Shaping: Uses Intl.Segmenter for grapheme-accurate text segmentation, natively handling Latin, CJK, and right-to-left (RTL) scripts on a shared baseline without compromise.
Pluggable Architecture: A strict two-stage pipeline separates Layout from Rendering, allowing developers to swap font managers and target different rendering backends (PDF, Canvas, test spies) seamlessly.
JSON Layout AST: Because the layout output is purely JSON, developers can snapshot it, diff it between versions, and reproduce layout bugs without rendering a single pixel.
The Edge-Native Performance Advantage VMPrint fundamentally rethinks document composition for the serverless era:
Unmatched Speed: On a modern ARM Snapdragon chip, VMPrint's most complex regression fixture (an 8-page document featuring mixed-script typography, floated images, and multi-page spanning tables) completes full layout and rendering in just ~28ms.
Eliminating Infrastructure Bloat: By avoiding headless browsers, companies no longer need to maintain heavy background job queues just to generate documents. VMPrint is fast enough to serve complex PDFs synchronously in edge environments.
Automated Pagination: Unlike low-level PDF libraries that require developers to manually write while loops to cut paragraphs and carry tables across pages, VMPrint handles complex contextual pagination automatically.
Seamless Integration VMPrint's platform-agnostic design abstracts the complexities of font loading and text wrapping through simplified interfaces.
Example Usage:
JavaScript
import { LayoutEngine, Renderer } from '@vmprint/engine';
const engine = new LayoutEngine(config, runtime);
await engine.waitForFonts();
// Stage 1: Generate a deterministic layout AST
const pages = engine.paginate(document.elements);
// Stage 2: Proceed to render to your chosen context (PDF, Canvas, etc.)
const renderer = new Renderer(config, false, runtime);
await renderer.render(pages, context);
By utilizing VMPrint, developers can shift towards a rigorous, standards-compliant approach to document generation. Whether compiling automated invoices, complex academic reports, or industry-standard screenplays, VMPrint delivers the uncompromising quality and extreme performance necessary for the modern web.
No comments yet.
Sign in to be the first to comment.