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

pdf-to-dxf

v1.0.3

Published

Convert PDF files to AutoCAD DXF format — React component + CLI. Part of the ek-mc civil toolset.

Readme

pdf-to-dxf

npm version npm downloads License: MIT CI

Live: https://ek-mc.github.io/pdf-to-dxf/

npm: https://www.npmjs.com/package/pdf-to-dxf

A robust, fully local PDF to AutoCAD DXF converter. It extracts vector paths and text from PDF files and converts them into DXF format.

This tool is part of the ek-mc civil toolset. It operates entirely on your local machine—no cloud uploads, ensuring your data remains private and secure.

Features

  • Dual-mode: Use it as a standalone CLI tool or embed it as a React component.
  • Local processing: Zero external API calls; your files never leave your machine.
  • Local PDF.js worker: Browser worker is bundled/served locally (no CDN dependency).
  • Vector extraction: Accurately extracts lines, curves (approximated as polylines), and rectangles.
  • Text extraction: Preserves text elements with their relative positioning.
  • Customizable: Supports page selection, coordinate scaling, and layer prefixing.

Installation

You can install pdf-to-dxf globally to use the CLI, or locally in your project to use the React component.

# Install globally for CLI usage
npm install -g @ek-mc/pdf-to-dxf

# Or install locally in your project
npm install @ek-mc/pdf-to-dxf

CLI Usage

If installed globally, you can run pdf-to-dxf directly from your terminal. Alternatively, use npx without installing:

npx pdf-to-dxf input.pdf [output.dxf] [options]

Examples

Convert a single file (outputs to drawing.dxf):

pdf-to-dxf drawing.pdf

Convert specific pages and apply a scale factor (e.g., from points to millimeters):

pdf-to-dxf plan.pdf plan_scaled.dxf --pages 1,2,3 --scale 0.3527

Exclude text entities:

pdf-to-dxf schematic.pdf --no-text

CLI Options

| Option | Description | Default | |--------|-------------|---------| | --pages <1,2> | Comma-separated list of pages to convert (1-indexed). | All pages | | --scale <num> | Uniform scale factor applied to all coordinates. | 1 | | --layer-prefix <name> | Prefix for generated DXF layer names. | PAGE | | --no-text | Exclude text entities from the output. | false | | --no-paths | Exclude vector path entities from the output. | false | | --help, -h | Show the help message. | | | --version, -v | Show the package version. | |

React Component Usage

The package includes a ready-to-use React component that provides a drag-and-drop interface for converting PDFs to DXF in the browser.

import React from 'react';
import { PdfToDxf } from '@ek-mc/pdf-to-dxf';

export default function App() {
  return (
    <div>
      <h1>PDF to DXF Converter</h1>
      <PdfToDxf 
        options={{ scale: 1, includeText: true }}
        onComplete={(result, filename) => {
          console.log(`Converted ${result.pageCount} pages. Downloaded as ${filename}`);
        }}
        onError={(error) => {
          console.error('Conversion failed:', error);
        }}
      />
    </div>
  );
}

Component Props

| Prop | Type | Description | |------|------|-------------| | options | ConvertOptions | Configuration options for the conversion engine. | | onComplete | (result: ConvertResult, filename: string) => void | Callback fired when conversion succeeds. | | onError | (error: Error) => void | Callback fired when conversion fails. | | className | string | Optional CSS class name for the wrapper element. |

Core Engine API

If you need programmatic access without the UI, you can use the core conversion function directly.

import { convertPdfToDxf } from '@ek-mc/pdf-to-dxf';

// Read your PDF into an ArrayBuffer or Uint8Array
const buffer = await file.arrayBuffer();

const result = await convertPdfToDxf(buffer, {
  pages: [1],
  scale: 1,
  layerPrefix: 'CUSTOM_LAYER',
  includeText: true,
  includePaths: true
});

console.log(result.dxf); // The resulting DXF string

License

MIT License. See the LICENSE file for details.