Skip to content

A utility for Unix-like operating systems to print files from Node.js and Electron.

License

Notifications You must be signed in to change notification settings

quesoft-it/qs-unix-print

 
 

Repository files navigation

QS-Unix-print

FORK OF artiebits/unix-print

A utility for Unix-like operating systems to print files from Node.js and Electron.

  • Understands different types of files, such as PDF, text, PostScript, and image files.
  • Works with type of Buffer if don't want to save files before.
  • Supports label printers such as Rollo and Zebra.

Table of Contents

Basic Usage

Print a PDF file or Buffer of PDF file to the default printer:

import { print } from "unix-print";

print("assets/file.pdf").then(console.log);

Installation

Install using npm:

npm install --save qs-unix-print

API

print(pdf, printer, options) => Promise<void>

A function to print a file to a printer.

Arguments

Argument Type Optional Description
file string or Buffer Required A file or Buffer to print.
printer string Optional Print a file to the specific printer.
options string[] Optional Any option from this list.

Returns

Promise<void>.

To print a file to the default printer:

import { print } from "unix-print";

print("assets/file.pdf").then(console.log);

To print a file to a specific printer:

import { print } from "unix-print";

const fileToPrint = "assets/file.pdf";
const printer = "Zebra";

print(fileToPrint, printer).then(console.log);

With some printer-specific options:

import { print } from "unix-print";

const fileToPrint = "assets/file.jpg";
const printer = undefined;
const options = ["-o landscape", "-o fit-to-page", "-o media=A4"];

print("assets/file.jpg", printer, options).then(console.log);

getPrinters() => Promise<Printer[]>

Returns

Promise<Printer[]>: List of available printers.

Examples

import { getPrinters } from "unix-print";

getPrinters().then(console.log);

getDefaultPrinter() => Promise<Printer | null>

Returns

Promise<Printer | null>: System default printer or null.

Examples

import { getPrinters } from "unix-print";

getDefaultPrinter().then(console.log);

License

This project is licensed under the MIT License - see the LICENSE.md for details.

About

A utility for Unix-like operating systems to print files from Node.js and Electron.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 97.9%
  • JavaScript 1.4%
  • Shell 0.7%