v0.1.0 MIT License TypeScript

@cadview

A framework-agnostic CAD/DXF
file viewer for the web.

$ npm install @cadview/core
01
DXF Parser

Parses 13 DXF entity types including LINE, CIRCLE, ARC, SPLINE, POLYLINE, TEXT, MTEXT, and INSERT. Handles encoding detection and won't crash on malformed input.

02
Canvas 2D Renderer

Renders to Canvas 2D with DPR scaling. Dark and light themes, full ACI 256-color table. Supports nested block INSERTs and MINSERT grids.

03
Interactive Viewer

Pan and zoom via mouse wheel, trackpad pinch, or touch. Pointer capture keeps input working even outside the canvas. Zoom speed and min/max are configurable.

04
Entity Selection

Uses an R-tree (rbush) for spatial indexing, so hit-testing stays fast even with thousands of entities. Picking is based on geometric distance, not bounding boxes.

05
Measurement Tool

Snaps to endpoints, midpoints, and centers. Shows distance, delta X/Y, and angle as you measure, drawn directly on the canvas.

06
Framework Wrappers

Drop-in components for React, Svelte 5, and Vue 3. Props are reactive, events are callbacks, and each wrapper ships a hook or composable.

No file loadedโ–ˆ
import { CadViewer } from '@cadview/core';
import { dwgConverter } from '@cadview/dwg'; // optional

const canvas = document.getElementById('canvas');
const viewer = new CadViewer(canvas, {
  theme: 'dark',
  formatConverters: [dwgConverter] // DWG support
});

// Load from File input (.dxf or .dwg)
const file = input.files[0];
await viewer.loadFile(file);
viewer.fitToView();

// Selection & measurement
viewer.setTool('select');
viewer.on('select', (e) => {
  console.log(e.entity.type, e.entity.layer);
});

viewer.destroy();
EntityDescription
LINELine segments
CIRCLEFull circles
ARCCircular arcs
LWPOLYLINELightweight polylines with bulge arcs
POLYLINELegacy polylines
ELLIPSEEllipses and elliptical arcs
SPLINEB-splines (NURBS curves)
TEXTSingle-line text
MTEXTMulti-line formatted text
INSERTBlock references with MINSERT grid
DIMENSIONDimension annotations via geometry blocks
HATCHHatch fills with line, arc, and circle edges
POINTPoint markers
@cadview/core

DXF parser, Canvas 2D renderer, interactive viewer engine

v0.1.0 npm docs
@cadview/react

React 18/19 component & hook

v0.1.0 npm
@cadview/svelte

Svelte 5 component (runes)

v0.1.0 npm
@cadview/vue

Vue 3 component & composable

v0.1.0 npm
// extensions
@cadview/dwg GPL-3.0

DWG file support via LibreDWG WASM

v0.1.0 npm