MatteoMeil / node-native-printer

Node module to print from nodejs apps
83 stars 39 forks source link

node-native-printer

A node module to natively print your files

Requirements

Imporant notes

Due to important differences in enviroments and ecosystems between Microsoft and Unix-based systems, this module has been written in C++ for Unix and C# for Windows. This can result in different behaviours during the execution of the methods (such as different execution time, returning values, allowed options for printer, etc.).


Installation

npm install node-native-printer --save

You will be prompted for selecting edge backend based on installed packages that contains the word "edge". If you wish to enter manually the name of edge backend package, select Not listed and type it manually.

Flags (Windows only)

Usage

First of all you need to require the module inside your app this way:

const printer = require('node-native-printer');

Then you can set a printer to work on, calling setPrinter(printerName). In this way you don't need to pass else the printer name on each method it's required.

API

listPrinters()

    return an array with all installed printers

defaultPrinterName()

    return the default printer name

setPrinter(printer)

    set the printer to work on

getCurrentPrinter()

    get current printer you are working on

printerInfo(printer)

    return general info about current working printer such jobs and options:

printerOptions(printer)

    return printer-specific options:

print(filename[, options, printer])

printText(text[, options, printer])

Same as print() but you can pass directly a string of text on the first parameter.

Electron Packaging (Windows only)

As from electron's docs, there are two methods of packaging your app: with one of the builders or manually making your own an asar archive.