cups-printer
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

CUPS Printer

A package to print documents using CUPS Printer Server in Linux. It's an ESM package written in typescript, using ava as testing library.

Installation

In your project, just type:

npm i --save cups-printer

How to use

Fow now, this package only gets printers and use these devices to print documents.

import { Printer } from 'cups-printer';
import { readFile } from 'fs/promises';

// Getting all printers installed in CUPS.
const all = await Printer.all();

// Finding directly a particular printer using a delegate.
const obj = await Printer.find(x => x.name.startsWith('EPSON'));

// Printing a PDF file...
await obj.print('document.pdf');

// ...or printing a buffer.
const byte = await readFile('document.pdf');
await obj.print(byte);

Typescript configuration

This package is an ECMAScript module, so the recommended configuration is settled using this in mind. Remember put in your package.json:

{
    "type": "module"
}

The tsconfig.json minimum recomended configuration is:

{
    "compilerOptions": {
        "target": "ES2022",
        "module": "ES2022",

        "outDir": "./dist",
        "rootDir": "./src",

        "strict": true,
        "moduleResolution": "node"
    }
}

Package Sidebar

Install

npm i cups-printer

Weekly Downloads

3

Version

0.2.0

License

MIT

Unpacked Size

17.3 kB

Total Files

33

Last publish

Collaborators

  • sleep-written