@luckykiet/node-printer 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -42
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,61 +1,85 @@
|
|
|
1
|
-
|
|
2
|
-
============
|
|
3
|
-
Native bind printers on POSIX and Windows OS from Node.js, electron and node-webkit.
|
|
1
|
+
# @luckykiet/node-printer
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
Native printer bindings for Node.js on POSIX and Windows. Fork of [@thiagoelg/node-printer](https://github.com/thiagoelg/node-printer) with **Node 24+ support**.
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@luckykiet/node-printer)
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
## What's different from the original?
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
- **Node 24/25 support** — C++20 build, updated V8 compatibility
|
|
10
|
+
- Updated native dependencies (`nan` 2.25+, `node-abi` 4.26+)
|
|
11
|
+
- macOS arm64 (Apple Silicon) prebuild support
|
|
12
|
+
- Modernized GitHub Actions (v4, Node 24)
|
|
13
|
+
- Minimum Node version: **20.0.0**
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
### **Below is the original README**
|
|
15
|
-
___
|
|
16
|
-
### Reason:
|
|
15
|
+
## Install
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
### Features:
|
|
17
|
+
```bash
|
|
18
|
+
npm install @luckykiet/node-printer
|
|
19
|
+
```
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
* native method wrappers from Windows and POSIX (which uses [CUPS 1.4/MAC OS X 10.6](http://cups.org/)) APIs;
|
|
25
|
-
* compatible with node v0.8.x, 0.9.x and v0.11.x (with 0.11.9 and 0.11.13);
|
|
26
|
-
* compatible with node-webkit v0.8.x and 0.9.2;
|
|
27
|
-
* `getPrinters()` to enumerate all installed printers with current jobs and statuses;
|
|
28
|
-
* `getPrinter(printerName)` to get a specific/default printer info with current jobs and statuses;
|
|
29
|
-
* `getPrinterDriverOptions(printerName)` ([POSIX](http://en.wikipedia.org/wiki/POSIX) only) to get a specific/default printer driver options such as supported paper size and other info
|
|
30
|
-
* `getSelectedPaperSize(printerName)` ([POSIX](http://en.wikipedia.org/wiki/POSIX) only) to get a specific/default printer default paper size from its driver options
|
|
31
|
-
* `getDefaultPrinterName()` return the default printer name;
|
|
32
|
-
* `printDirect(options)` to send a job to a specific/default printer, now supports [CUPS options](http://www.cups.org/documentation.php/options.html) passed in the form of a JS object (see `cancelJob.js` example). To print a PDF from windows it is possible by using [node-pdfium module](https://github.com/tojocky/node-pdfium) to convert a PDF format into EMF and after to send to printer as EMF;
|
|
33
|
-
* `printFile(options)` ([POSIX](http://en.wikipedia.org/wiki/POSIX) only) to print a file;
|
|
34
|
-
* `getSupportedPrintFormats()` to get all possible print formats for printDirect method which depends on OS. `RAW` and `TEXT` are supported from all OS-es;
|
|
35
|
-
* `getJob(printerName, jobId)` to get a specific job info including job status;
|
|
36
|
-
* `setJob(printerName, jobId, command)` to send a command to a job (e.g. `'CANCEL'` to cancel the job);
|
|
37
|
-
* `getSupportedJobCommands()` to get supported job commands for setJob() depends on OS. `'CANCEL'` command is supported from all OS-es.
|
|
21
|
+
### Build prerequisites
|
|
38
22
|
|
|
23
|
+
The native addon compiles from source if no prebuild is available.
|
|
39
24
|
|
|
40
|
-
|
|
25
|
+
**macOS:** Xcode Command Line Tools (ships with CUPS)
|
|
26
|
+
```bash
|
|
27
|
+
xcode-select --install
|
|
41
28
|
```
|
|
42
|
-
|
|
29
|
+
|
|
30
|
+
**Linux (Debian/Ubuntu):**
|
|
31
|
+
```bash
|
|
32
|
+
sudo apt-get install libcups2-dev
|
|
43
33
|
```
|
|
44
34
|
|
|
45
|
-
|
|
35
|
+
**Windows:** Visual Studio Build Tools with C++ workload
|
|
46
36
|
|
|
47
|
-
|
|
37
|
+
## API
|
|
48
38
|
|
|
49
|
-
|
|
39
|
+
```js
|
|
40
|
+
const printer = require('@luckykiet/node-printer');
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
| Method | Description |
|
|
44
|
+
|--------|-------------|
|
|
45
|
+
| `getPrinters()` | List all installed printers with jobs and statuses |
|
|
46
|
+
| `getPrinter(name)` | Get specific printer info |
|
|
47
|
+
| `getDefaultPrinterName()` | Get default printer name |
|
|
48
|
+
| `getPrinterDriverOptions(name)` | Get driver options (POSIX only) |
|
|
49
|
+
| `getSelectedPaperSize(name)` | Get default paper size (POSIX only) |
|
|
50
|
+
| `printDirect(options)` | Send raw data to printer |
|
|
51
|
+
| `printFile(options)` | Print a file (POSIX only) |
|
|
52
|
+
| `getSupportedPrintFormats()` | List supported formats (RAW, TEXT, PDF, etc.) |
|
|
53
|
+
| `getJob(printerName, jobId)` | Get job info |
|
|
54
|
+
| `setJob(printerName, jobId, command)` | Send command to job (e.g. CANCEL) |
|
|
55
|
+
| `getSupportedJobCommands()` | List supported job commands |
|
|
56
|
+
|
|
57
|
+
## Examples
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
const printer = require('@luckykiet/node-printer');
|
|
61
|
+
|
|
62
|
+
// List printers
|
|
63
|
+
console.log(printer.getPrinters());
|
|
64
|
+
|
|
65
|
+
// Print raw text
|
|
66
|
+
printer.printDirect({
|
|
67
|
+
data: 'Hello from Node.js!',
|
|
68
|
+
printer: printer.getDefaultPrinterName(),
|
|
69
|
+
type: 'TEXT',
|
|
70
|
+
success: (jobId) => console.log('Job ID:', jobId),
|
|
71
|
+
error: (err) => console.error(err),
|
|
72
|
+
});
|
|
73
|
+
```
|
|
50
74
|
|
|
51
|
-
|
|
75
|
+
See the [examples](./examples) directory for more usage patterns.
|
|
52
76
|
|
|
53
|
-
|
|
77
|
+
## Credits
|
|
54
78
|
|
|
55
|
-
|
|
56
|
-
|
|
79
|
+
- **Ion Lupascu** — original author ([tojocky/node-printer](https://github.com/tojocky/node-printer))
|
|
80
|
+
- **Thiago Lugli** ([@thiagoelg](https://github.com/thiagoelg)) — Node 12+ support & prebuild CI
|
|
81
|
+
- **Eko Eryanto** ([@ekoeryanto](https://github.com/ekoeryanto)) — prebuild integration
|
|
57
82
|
|
|
58
|
-
|
|
83
|
+
## License
|
|
59
84
|
|
|
60
|
-
|
|
61
|
-
[The MIT License (MIT)](http://opensource.org/licenses/MIT)
|
|
85
|
+
[MIT](http://opensource.org/licenses/MIT)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luckykiet/node-printer",
|
|
3
3
|
"description": "Node.js native printer bindings. Fork of @thiagoelg/node-printer with Node 24+ support.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"homepage": "https://github.com/luckykiet/node-printer",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Ion Lupascu",
|