Catalog npm
Back to packageRELEASE DETAILS

5.6.1

npm

@00f100/pdf-to-printer

A utility for printing PDFs and images from Node.js and Electron.

electronnode.jspdfpdf-printerprinterrollo-printerwindowszebra-printer
Published19 Apr 2023
Direct dependencies19
Transitive dependenciesNot calculated

README

Current package documentation

Node.js printing

Build Status codecov npm

A utility for printing PDFs and images from Node.js and Electron.

Support This Project

If you rely on this package, please consider supporting it. Maintaining an open source project takes time and your support would be greatly appreciated.

Buy Me A Coffee

Installation

You can install the package using npm:

npm install --save pdf-to-printer

Or yarn

yarn add pdf-to-printer

Basic Usage

To print a file to the default printer:

import { print } from "pdf-to-printer";

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

API

.print(pdf[, options]) => Promise<void>

A function that prints your file.

Arguments

  1. pdf (string, required): A path to the file you want to print. An error will be thrown if the PDF is not specified or not found.
  2. options (Object, optional):
    • printer ( string, optional): Sends the file to the specified printer.
    • pages (string, optional): Specifies which pages to print in the PDF document.
    • subset (string, optional): Prints odd pages only when the value is odd, and even pages only when it is even.
    • orientation (string, optional): Provides 90-degree rotation of contents (NOT the rotation of paper which must be pre-set by the choice of printer defaults).
    • scale (string, optional): Supported names are noscale, shrink, and fit.
    • monochrome (boolean, optional): Prints the document in black and white. The default value is false.
    • side (string, optional): Supported names are duplex, duplexshort, duplexlong, and simplex.
    • bin (string, optional): Select tray to print to. Number or name.
    • paperSize (string, optional): Specifies the paper size. A2, A3, A4, A5, A6, letter, legal, tabloid, statement, or a name selectable from your printer settings.
    • silent (boolean, optional): Silences error messages.
    • printDialog (boolean, optional): Displays the print dialog for all the files indicated on this command line.
    • copies(number, optional): Specifies how many copies will be printed.

Returns

Promise<void>: A Promise that resolves with undefined.

Examples

To print a file to the default printer, use the following code:

import { print } from "pdf-to-printer";

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

To print to a specific printer:

import { print } from "pdf-to-printer";

const options = {
  printer: "Zebra",
};

print("assets/pdf-sample.pdf", options).then(console.log);

Here is an example with a few print settings. It will print pages 1, 3, and 5, and scale them so that they fit into the printable area of the paper.

import { print } from "pdf-to-printer";

const options = {
  printer: "Zebra",
  pages: "1-3,5",
  scale: "fit",
};

print("assets/pdf-sample.pdf", options).then(console.log);

.getPrinters() => Promise<Printer[]>

A function to get a list of available printers.

Returns

Promise<Printer[]>: a Promise that resolves with a list of available printers.

Examples

import { getPrinters } from "pdf-to-printer";

getPrinters().then(console.log);

.getDefaultPrinter() => Promise<Printer | null>

A function to get the default printer information.

Returns

Promise<Printer | null>: a Promise that resolves with the default printer information, or null if there is no default printer.

Examples

import { getDefaultPrinter } from "pdf-to-printer";

getDefaultPrinter().then(console.log);

License

MIT

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 19

Native requirements
19 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
@babel/cli
Environment
{
  "local_name": "@babel/cli",
  "alias": false,
  "peer_metadata": null
}
7.21.0development
@babel/core
Environment
{
  "local_name": "@babel/core",
  "alias": false,
  "peer_metadata": null
}
7.20.12development
@babel/preset-env
Environment
{
  "local_name": "@babel/preset-env",
  "alias": false,
  "peer_metadata": null
}
7.20.2development
@babel/preset-typescript
Environment
{
  "local_name": "@babel/preset-typescript",
  "alias": false,
  "peer_metadata": null
}
^7.15.0development
@types/jest
Environment
{
  "local_name": "@types/jest",
  "alias": false,
  "peer_metadata": null
}
^29.2.6development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^18.6.3development
babel-jest
Environment
{
  "local_name": "babel-jest",
  "alias": false,
  "peer_metadata": null
}
^29.2.2development
clean-webpack-plugin
Environment
{
  "local_name": "clean-webpack-plugin",
  "alias": false,
  "peer_metadata": null
}
4.0.0development
copy-webpack-plugin
Environment
{
  "local_name": "copy-webpack-plugin",
  "alias": false,
  "peer_metadata": null
}
^11.0.0development
husky
Environment
{
  "local_name": "husky",
  "alias": false,
  "peer_metadata": null
}
^8.0.3development
jest
Environment
{
  "local_name": "jest",
  "alias": false,
  "peer_metadata": null
}
^29.5.0development
jest-mock
Environment
{
  "local_name": "jest-mock",
  "alias": false,
  "peer_metadata": null
}
^29.1.2development
lint-staged
Environment
{
  "local_name": "lint-staged",
  "alias": false,
  "peer_metadata": null
}
^13.0.0development
prettier
Environment
{
  "local_name": "prettier",
  "alias": false,
  "peer_metadata": null
}
2.8.4development
ts-jest
Environment
{
  "local_name": "ts-jest",
  "alias": false,
  "peer_metadata": null
}
^29.0.5development
ts-loader
Environment
{
  "local_name": "ts-loader",
  "alias": false,
  "peer_metadata": null
}
^9.2.6development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^4.9.4development
webpack
Environment
{
  "local_name": "webpack",
  "alias": false,
  "peer_metadata": null
}
^5.58.2development
webpack-cli
Environment
{
  "local_name": "webpack-cli",
  "alias": false,
  "peer_metadata": null
}
^5.0.0development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-OYCwJhTb9EIirH4lfci7nKwslN9ttaHUN5dZ3BcUzlU08Rj8Hzzl1umTj4HUdyiaiXeiuajgvWe3u0N3201dow==",
  "shasum": "ea794879a48c6b4854f98d68a17b95694c5b3227",
  "tarball": "https://registry.npmjs.org/@00f100/pdf-to-printer/-/pdf-to-printer-5.6.1.tgz",
  "fileCount": 13,
  "unpackedSize": 12678045,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEYCIQC/9SLbVYYu+CP+GQj1vfU9W1c49Y8C1n/Yf2MkbGJNVgIhAP4/D05d2JCItKwYo0CvYLToj2sqQ344XUAGKqjurzjN"
    }
  ],
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkP/0HACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqKbA/9Gc3T4K9BU2LNtKp+LkkjrgZ6NQNrsHQ/SLn9yzV7jqicNjGA\r\nmCixTM8w2ATVrNa2LEMU70T51MOd7XfiqSLj1FvRkTUXvzpA4oC89MDXCPq/\r\n9XqS0lRkAFwXRD4olEfzGg2NPA+iVsTkqt03oUNLYEdeZ5EfzkwcVoT3sRtn\r\nTEJubVqrbgC3VMmcSKj9hNF5B6MfJceZ/ShoAyiS/ddCiQ0rdNnzF8HFfjyK\r\ntfAF2t6aphrZeaLbf6sI5X2Ujk8n6iYQb0iMt7D/kyZlGJc251HkYECEwEeQ\r\nVIGAQZSs9P7WlhvDNdgpMiG1ijDtIYD5iYUEhneIy0TAbwEkwfHG4UW2fQyt\r\nzqXdBG/lJtZyOvPaenDrWTJm1how4OX/ubl31vawdNL7WseHDvnytk7YfXHn\r\npv9BDrJr/AVb4/HlzOCke3XMRkV28Y+3tbIizjdZ7wq7k+jzc5356cGJ0xNJ\r\nw1CpMCxCcP0FRIRPmm00PKfM1EzXDMXl+DDj3iEU0ELG558ceJN6xuCzd3wU\r\ns8k/ZD/IzNeipdxNcbZHbSYXJo813vya10DmDTbbbpTyNToD+HHe3O7lqyFS\r\nFXDKIGktaoHWN2GoQ9wMwcMMzMKiINW7/gJZg9AeV11iDsAIzxiyihObRTB1\r\nUml0pc9SRyK1w1W6zTjfH7u/+RzOqilepfI=\r\n=oGcU\r\n-----END PGP SIGNATURE-----\r\n"
}

Repository

PENDING
00f100/pdf-to-printer

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 21:54 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:89e660d15519273ecffbca079d59f927bbccd0f771cd62d584888a4832ddc560

Other collected versions

5.6.519 Apr5.6.419 Apr5.6.319 Apr5.6.219 AprView all collected versions →