DOM -> IR -> Writers TypeScript ESM CAD + Vector + Raster

layout2vector turns rendered web layouts into production-ready files.

Extract live DOM geometry (HTML, SVG, transforms, form controls, optional same-origin iframes) and write it as DXF, DWG, EMF/EMF+, PDF, SVG, PNG/JPEG/WEBP, Canvas, or standalone HTML.

Why teams pick it

One extraction, many targets One intermediate representation feeds CAD, print, vector, and raster outputs so your export logic stays consistent.
Text and geometry stay structured Unlike screenshot-only pipelines, text-capable writers keep editable text where possible.
Built for technical workflows DXF, DWG, EMF, and EMF+ support is first-class, not an afterthought via raster conversion.

Quick code sample

import { extractIR, renderIR, DXFWriter, PDFWriter } from "@node-projects/layout2vector"; const root = document.getElementById("layout")!; const ir = await extractIR(root, { includeImages: true, includeText: true, convertFormControls: true, walkIframes: true }); const dxf = await renderIR(ir, new DXFWriter({ maxY: document.documentElement.scrollHeight })); const pdfDoc = await renderIR(ir, new PDFWriter()); await pdfDoc.finalize(); const pdfBytes = pdfDoc.toBytes();

Advanced example pages

Complex PDF with embedded WOFF/WOFF2 fonts Uses extractIRWithAssets() and PDFWriter({ useFontEditorCore: true }) so non-TTF webfonts are converted and embedded in the exported PDF.

Open example

One extraction to multiple writers Produces DXF, SVG, HTML, and PNG outputs from one IR extraction pass to keep all artifacts in sync.

Open example

CAD + EMF export bundle Generates DWG, Acad DXF, EMF, and EMF+ together for mixed CAD and Windows vector workflows.

Open example

Need browser-webfont fidelity for CAD/EMF? See the font fallback example.

Advantages over screenshot-focused libraries

Capability layout2vector Typical screenshot libs
Native DXF / DWG / EMF / EMF+ Yes No
Structured IR for custom exporters Yes Usually no
Keeps text as text in vector/document outputs Yes Mostly rasterized
Standalone HTML and native SVG writers Yes Rare / partial
Screenshot outputs (PNG/JPEG/WEBP/Canvas) Yes Yes

For a detailed matrix with html2canvas, html2canvas-pro, and SnapDOM, see FEATURES.md.

Example outputs