Skip to content

apenab/dymo-print-suite

dymo-print-suite

npm version npm version License: MIT

TypeScript-first toolkit to interact with DYMO LabelWriter printers via the DYMO Web Service.

Features

  • Typed helpers - XML request/response handling with full TypeScript support
  • React hooks - Easy integration with React applications
  • Abortable requests - Cancel pending requests with AbortController
  • Printer discovery - Enumerate available DYMO printers
  • Label preview - Render labels as PNG images before printing

Packages

Package Description Docs
@dymo-print-suite/core TypeScript utilities (no React dependency) README
@dymo-print-suite/react React hooks + re-exports from core README

Installation

For React projects:

npm install @dymo-print-suite/react
# or
pnpm add @dymo-print-suite/react

For non-React projects:

npm install @dymo-print-suite/core
# or
pnpm add @dymo-print-suite/core

Quick Start

React

import {
  useDymoCheckService,
  useDymoFetchPrinters,
  printLabel,
} from "@dymo-print-suite/react";

const labelXml = `<?xml version="1.0" encoding="utf-8"?>
<DieCutLabel Version="8.0" Units="twips">
  <PaperOrientation>Landscape</PaperOrientation>
  <ObjectInfo Name="Text">
    <TextObject>
      <StyledText><String>Hello World</String></StyledText>
    </TextObject>
  </ObjectInfo>
</DieCutLabel>`;

function App() {
  const status = useDymoCheckService();
  const { printers, statusFetchPrinters } = useDymoFetchPrinters(status);

  if (status === "loading") return <p>Checking DYMO service...</p>;
  if (status === "error") return <p>DYMO service not available</p>;

  return (
    <div>
      <h1>Available Printers</h1>
      {statusFetchPrinters === "success" && (
        <ul>
          {printers.map((p) => (
            <li key={p.name}>
              {p.name}
              <button onClick={() => printLabel(p.name, labelXml)}>
                Print
              </button>
            </li>
          ))}
        </ul>
      )}
    </div>
  );
}

Core (non-React)

import { dymoRequestBuilder, printLabel } from "@dymo-print-suite/core";

// Check service status
const response = await dymoRequestBuilder({
  method: "GET",
  wsAction: "status",
});

// Print a label
await printLabel("DYMO LabelWriter 450", labelXml);

Migration from react-dymo-hooks

If you were using react-dymo-hooks, update your imports:

- import { useDymoCheckService, printLabel } from "react-dymo-hooks";
+ import { useDymoCheckService, printLabel } from "@dymo-print-suite/react";

The API remains compatible. See MIGRATION.md for details.

Documentation

Example App

pnpm install
pnpm --filter dymo-print-suite-example dev

Development

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Run tests
pnpm test

# Run tests in watch mode
pnpm test:watch

Requirements

  • DYMO Label Web Service must be installed and running on the user's machine
  • Supported browsers: Chrome, Firefox, Edge, Safari

License

MIT © apenab

About

TypeScript-first toolkit to interact with DYMO LabelWriter printers via the DYMO Web Service.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors