| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A node module to natively print your files
edge, electron-edge (depending on your environment) or any other fork of these. The package you choose should be installed before node-native-printer. During installation you'll be prompted to select which package do
you want to use.
BE CAREFULLY: it will be listed all packages in node_modules containing the word "edge"; be sure to make the right choice
If you wish, you can manually specify which fork of edge or electron-edge to use. See installation
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.).
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.
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.
return an array with all installed printers
return the default printer name
set the printer to work on
get current printer you are working on
return general info about current working printer such jobs and options:
return printer-specific options:
printer: name of the printer to print on. If not specified it will print on previously setted printer. If printer is not set it will print on default printer.
Returning value:
{
"Collate": "array containing collation options",
"Duplexing": "array containing collation options",
"MaxCopy": "max number of copies you can send to printer",
"SupportsColor": "boolean indicating whether a print can print with colors",
"PaperSheets": "available paper formats supported from printer. If custom is present it can be submitted custom width and height",
"Resolutions": "printer resolutions (i.e.: High, Medium)"
}Windows: default options:
{
"collate": true,
"color": true,
"copies": 1,
"duplex": "Default",
"landscape": false,
"paperSize": "",
"fromPage": 0,
"toPage": 0
}List of supported extensions can be found here
Notes: duplex is case sensitive, so be careful to write correctly. "paperSize" refers to size of sheet to print on; if you want to print on a paper with custom dimensions, pass "Custom.WidthxHeight" where Width and Height are integer dimensions in hundredths of inch. "fromPage": 0 means document will be printed from first page; "toPage": 0 means document will be printed from "fromPage" to last page.
Unix: you can use command-line options in JSON-style and/or printer-specific options retrieved from printerOptions(); i.e.:
{
"landscape": true,
"n": 2,
"sides": "two-sided-long-edge"
}For options that doesn't have a value (like landscape or fit-to-page) you can assign a boolean (see above)
It will be generated and executed a command like lp -d printerName /path/to/filename -o landscape -n 2 -o sides=two-sided-long-edge
Same as print() but you can pass directly a string of text on the first parameter.
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.
"build": {
"npmArgs": "--production"
}
/app folder
+-- ...
+-- resources/
+-- app.asar
+-- electron.asar
+-- app.asar.unpacked/
+-- node_modules/
+-- node-native-printer/
+-- lib/
+-- windows/
+-- nl/
+-- x64/
+-- x86/
+-- PdfiumViewer.dll
+-- PdfiumViewer.xml
+-- windows_printer.dll
| Back | FazBrowse Home | New Git URL |