npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dxf-dogstar

v5.3.1-dogstar.0

Published

DXF parser and SVG exporter with Dogstar extensions for scale, layer filtering, fit-to-content padding, and source lineweight support.

Readme

dxf-dogstar

dxf-dogstar is a DXF parser and SVG exporter derived from the dxf project v5.3.1., with a focus on practical SVG export controls for CAD workflows.

What This Fork Adds

Compared with the upstream dxf package, this fork adds SVG export features that are useful when DXF files need to be rendered more predictably in web or document pipelines:

  • Optional scale for fixed pixel output
  • Responsive default SVG sizing when scale is omitted
  • Layer filtering with a layer-name array
  • UTF-8 / Chinese layer-name filtering support in normal Node.js string usage
  • Fit-to-content export behavior
  • Padding around exported content
  • Source lineweight support from DXF data where available

Install

npm install dxf-dogstar

Basic Usage

const fs = require('fs');
const { Helper } = require('dxf-dogstar');

const dxfText = fs.readFileSync('drawing.dxf', 'utf8');
const helper = new Helper(dxfText);

const svg = helper.toSVG();
fs.writeFileSync('drawing.svg', svg, 'utf8');

When scale is not provided, the generated SVG uses:

  • width="100%"
  • height="100%"

This is helpful when fixed pixel output makes thin horizontal or vertical strokes look too light in some renderers.

SVG Export Options

helper.toSVG(options) accepts these options:

  • scale?: number When provided, output SVG width and height are written in pixels. Example: scale: 2 means the exported SVG dimensions are doubled from drawing units.
  • layers?: string[] Export only entities whose layer is included in the array.
  • fitToContent?: boolean Default: true When true, export is cropped to the rendered content bounds.
  • padding?: number | { top:number, right:number, bottom:number, left:number } Padding in drawing units, applied around the exported content.
  • useSourceLineweight?: boolean Default: true Uses DXF lineweight or polyline constant width when available.
  • defaultStrokeWidth?: number Fallback stroke width when source lineweight is unavailable.

Example: Fixed Pixel Export

const fs = require('fs');
const { Helper } = require('dxf-dogstar');

const dxfText = fs.readFileSync('drawing.dxf', 'utf8');
const helper = new Helper(dxfText);

const svg = helper.toSVG({
  scale: 2,
  fitToContent: true,
  padding: { top: 10, right: 20, bottom: 10, left: 20 },
  useSourceLineweight: true,
});

fs.writeFileSync('drawing-2x.svg', svg, 'utf8');

Example: Export Specific Layers

const fs = require('fs');
const { Helper } = require('dxf-dogstar');

const dxfText = fs.readFileSync('drawing.dxf', 'utf8');
const helper = new Helper(dxfText);

const svg = helper.toSVG({
  layers: ['c-建筑轮廓', 'A-WALL'],
  fitToContent: true,
  padding: 0,
});

fs.writeFileSync('layers.svg', svg, 'utf8');

Example: Responsive Default Sizing

const fs = require('fs');
const { Helper } = require('dxf-dogstar');

const dxfText = fs.readFileSync('drawing.dxf', 'utf8');
const helper = new Helper(dxfText);

const svg = helper.toSVG({
  layers: ['c-建筑轮廓'],
  fitToContent: true,
  padding: 0,
});

fs.writeFileSync('responsive.svg', svg, 'utf8');

This output uses width="100%" height="100%" because scale is omitted.

Notes

  • This fork keeps the original project structure so existing Helper, parseString, denormalise, and related imports remain familiar.
  • SVG rendering still depends on the entity types supported by the upstream renderer.
  • The added lineweight logic is intended to improve practical SVG output, but exact print-style reproduction may still depend on DXF authoring conventions and external CAD print-style rules.

Development Note

The added Dogstar SVG export enhancements in this fork were developed with Codex GPT-5.4 assistance.

Upstream Project Attribution

This package is a derivative work based on the original dxf project:

  • Upstream project: dxf
  • Original author listed in the packaged source: Ben Nortier
  • Upstream license: MIT

License

This fork is distributed under the MIT License.

The original upstream copyright notice and MIT license text are retained in LICENSE.