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 🙏

© 2024 – Pkg Stats / Ryan Hefner

qs-pdf-to-printer

v5.7.12

Published

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

Downloads

57

Readme

Node.js printing

FORK OF artiebits/pdf-to-printer

IMPORTANT!!! - Project has editet in common ways, README hasn't been updated yet, but we will do it soon.

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

  • Available only on Windows. The Unix-like operating systems utility can be found on https://github.com/quesoft-it/qs-unix-print.
  • It supports label printers like Rollo and Zebra.

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.

Installation

You can install the package using npm:

npm install --save qs-pdf-to-printer

Basic Usage

To print a file to the default printer:

import { print } from "qs-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 "qs-pdf-to-printer";

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

To print to a specific printer:

import { print } from "qs-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 "qs-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 "qs-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 "qs-pdf-to-printer";

getDefaultPrinter().then(console.log);

License

MIT