Browser display context for vmprint.
ContextCanvas is a first-class screen-rendering context. It builds page scenes and exposes helpers to paint those pages onto HTML canvas or OffscreenCanvas targets. This keeps the browser product centered on screen display and interaction without exposing the scene format as part of the public API.
textRenderMode: 'text' keeps text as text and embeds the required fonts for faithful page previewtextRenderMode: 'glyph-path' converts all text to Fontkit glyph outlines for the fastest and most robust heavy-document preview pathfillText()import { CanvasContext } from '@vmprint/context-canvas';
const context = new CanvasContext({
size: 'LETTER',
margins: { top: 0, right: 0, bottom: 0, left: 0 },
autoFirstPage: false,
bufferPages: false,
textRenderMode: 'glyph-path'
});
// render with vmprint's engine/renderer...
await context.renderPageToCanvas(0, canvasElement, {
scale: 1,
dpi: 144
});
pipe() is a no-op. This context manages page scenes internally.toSvgString() and toSvgPages() when needed.renderPageToCanvas() accepts dpi so the canvas backing bitmap can be sharper than the displayed page size.text: simpler Latin or single-script documentsglyph-path: multilingual fidelity and lowest perceived first-view latency on heavy documentsLicensed under the Apache License 2.0.