@timokunze/node-printer 0.6.5 → 0.6.7

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@timokunze/node-printer",
3
3
  "description": "Node.js printer bindings",
4
- "version": "0.6.5",
4
+ "version": "0.6.7",
5
5
  "homepage": "https://github.com/TimoKunze/node-printer",
6
6
  "author": {
7
7
  "name": "Ion Lupascu",
@@ -18,7 +18,6 @@
18
18
  "url": "git://github.com/TimoKunze/node-printer.git"
19
19
  },
20
20
  "devDependencies": {
21
- "nodeunit": "^0.11.3",
22
21
  "node-gyp": "^10.1.0",
23
22
  "prebuild": "^13.0.0",
24
23
  "node-abi": "^3.62.0",
@@ -32,8 +31,7 @@
32
31
  "apply-patches": "patch-package",
33
32
  "prebuild-all": "prebuild --all --force --strip --verbose --openssl_fips=X",
34
33
  "prebuild": "prebuild",
35
- "rebuild": "node-gyp rebuild",
36
- "test": "nodeunit test"
34
+ "rebuild": "node-gyp rebuild"
37
35
  },
38
36
  "binary": {
39
37
  "module_name": "node_printer",
package/src/macros.hh CHANGED
@@ -13,10 +13,8 @@
13
13
  # define V8_VALUE_NEW(type, value) v8::type::New(MY_NODE_MODULE_ISOLATE, value)
14
14
  # define V8_VALUE_NEW_DEFAULT(type) v8::type::New(MY_NODE_MODULE_ISOLATE)
15
15
  # if NODE_MODULE_VERSION > 73
16
- # define V8_STRING_NEW_UTF8(value) v8::String::NewFromUtf8(MY_NODE_MODULE_ISOLATE, value).ToLocalChecked()
17
16
  # define V8_STRING_NEW_2BYTES(value) v8::String::NewFromTwoByte(MY_NODE_MODULE_ISOLATE, value).ToLocalChecked()
18
17
  # else
19
- # define V8_STRING_NEW_UTF8(value) v8::String::NewFromUtf8(MY_NODE_MODULE_ISOLATE, value)
20
18
  # define V8_STRING_NEW_2BYTES(value) v8::String::NewFromTwoByte(MY_NODE_MODULE_ISOLATE, value)
21
19
  # endif
22
20
 
@@ -43,6 +41,16 @@
43
41
  # define MY_NODE_MODULE_RETURN_UNDEFINED() return scope.Close(v8::Undefined())
44
42
  #endif
45
43
 
44
+ #if NODE_VERSION_AT_LEAST(4, 3, 0)
45
+ # define V8_STRING_NEW_UTF8(value) v8::String::NewFromUtf8(MY_NODE_MODULE_ISOLATE, value, v8::NewStringType::kNormal).ToLocalChecked()
46
+ #elif NODE_VERSION_AT_LEAST(0, 11, 10)
47
+ # if NODE_MODULE_VERSION > 73
48
+ # define V8_STRING_NEW_UTF8(value) v8::String::NewFromUtf8(MY_NODE_MODULE_ISOLATE, value).ToLocalChecked()
49
+ # else
50
+ # define V8_STRING_NEW_UTF8(value) v8::String::NewFromUtf8(MY_NODE_MODULE_ISOLATE, value)
51
+ # endif
52
+ #endif
53
+
46
54
  #if NODE_VERSION_AT_LEAST(4, 0, 0)
47
55
  #define V8_LOCAL_STRING_FROM_VALUE(value) value->ToString(Nan::GetCurrentContext()).FromMaybe(v8::Local<v8::String>())
48
56
  #define REQUIRE_ARGUMENT_INTEGER(args, i, var) \
@@ -1,87 +0,0 @@
1
- name: Prebuild Binaries and Publish
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- jobs:
9
- prebuild-linux:
10
- name: Prebuild Binaries for Linux
11
- runs-on: ubuntu-latest
12
- timeout-minutes: 30
13
- steps:
14
- - name: Setup Dependencies
15
- run: |
16
- sudo apt-get update -y -qq
17
- sudo apt-get install -y g++-multilib gcc-multilib libcups2-dev linux-libc-dev
18
- - uses: actions/setup-node@v4
19
- with:
20
- node-version: 20.x
21
- - uses: actions/checkout@v4
22
- - run: npm i
23
- - name: Prebuild
24
- run: |
25
- npm run apply-patches
26
- npm run prebuild -- --strip --all --arch x64 -u ${{ secrets.PREBUILD_TOKEN }}
27
- prebuild-linux-32:
28
- name: Prebuild Binaries for Linux
29
- runs-on: ubuntu-latest
30
- timeout-minutes: 30
31
- steps:
32
- - name: Setup Dependencies
33
- run: |
34
- sudo dpkg --add-architecture i386
35
- sudo apt-get update -y -qq
36
- sudo apt-get install -y g++-multilib gcc-multilib libcups2-dev libcups2-dev:i386 libc6-dev-i386 linux-libc-dev linux-libc-dev:i386
37
- - uses: actions/setup-node@v4
38
- with:
39
- node-version: 20.x
40
- - uses: actions/checkout@v4
41
- - run: npm i
42
- - name: Prebuild
43
- run: |
44
- npm run apply-patches
45
- npm run prebuild -- --strip --all --arch ia32 -u ${{ secrets.PREBUILD_TOKEN }}
46
- prebuild-macos:
47
- name: Prebuild Binaries for macOS
48
- runs-on: macos-latest
49
- timeout-minutes: 30
50
- steps:
51
- - uses: actions/setup-node@v4
52
- with:
53
- node-version: 20.x
54
- - uses: actions/checkout@v4
55
- - run: npm i
56
- - name: Prebuild
57
- run: |
58
- npm run apply-patches
59
- npm run prebuild -- --strip --all --arch x64 -u ${{ secrets.PREBUILD_TOKEN }}
60
- prebuild-windows:
61
- name: Prebuild Binaries for Windows x64
62
- runs-on: windows-latest
63
- timeout-minutes: 30
64
- steps:
65
- - uses: actions/setup-node@v4
66
- with:
67
- node-version: 20.x
68
- - uses: actions/checkout@v4
69
- - run: npm i
70
- - name: Prebuild
71
- run: |
72
- npm run apply-patches
73
- npm run prebuild -- --strip --all --arch x64 -u ${{ secrets.PREBUILD_TOKEN }}
74
- prebuild-windows-32:
75
- name: Prebuild Binaries for Windows ia32
76
- runs-on: windows-latest
77
- timeout-minutes: 30
78
- steps:
79
- - uses: actions/setup-node@v4
80
- with:
81
- node-version: 20.x
82
- - uses: actions/checkout@v4
83
- - run: npm i
84
- - name: Prebuild
85
- run: |
86
- npm run apply-patches
87
- npm run prebuild -- --strip --all --arch ia32 -u ${{ secrets.PREBUILD_TOKEN }}
@@ -1,85 +0,0 @@
1
- name: Prebuild Binaries
2
-
3
- on:
4
- pull_request:
5
-
6
- jobs:
7
- prebuild-linux:
8
- name: Prebuild Binaries for Linux
9
- runs-on: ubuntu-latest
10
- timeout-minutes: 30
11
- steps:
12
- - name: Setup Dependencies
13
- run: |
14
- sudo apt-get update -y -qq
15
- sudo apt-get install -y g++-multilib gcc-multilib libcups2-dev linux-libc-dev
16
- - uses: actions/setup-node@v4
17
- with:
18
- node-version: 20.x
19
- - uses: actions/checkout@v4
20
- - run: npm i
21
- - name: Prebuild
22
- run: |
23
- npm run apply-patches
24
- npm run prebuild -- --strip --all --arch x64
25
- prebuild-linux-32:
26
- name: Prebuild Binaries for Linux
27
- runs-on: ubuntu-latest
28
- timeout-minutes: 30
29
- steps:
30
- - name: Setup Dependencies
31
- run: |
32
- sudo dpkg --add-architecture i386
33
- sudo apt-get update -y -qq
34
- sudo apt-get install -y g++-multilib gcc-multilib libcups2-dev libcups2-dev:i386 libc6-dev-i386 linux-libc-dev linux-libc-dev:i386
35
- - uses: actions/setup-node@v4
36
- with:
37
- node-version: 20.x
38
- - uses: actions/checkout@v4
39
- - run: npm i
40
- - name: Prebuild
41
- run: |
42
- npm run apply-patches
43
- npm run prebuild -- --strip --all --arch ia32
44
- prebuild-macos:
45
- name: Prebuild Binaries for macOS
46
- runs-on: macos-latest
47
- timeout-minutes: 30
48
- steps:
49
- - uses: actions/setup-node@v4
50
- with:
51
- node-version: 20.x
52
- - uses: actions/checkout@v4
53
- - run: npm i
54
- - name: Prebuild
55
- run: |
56
- npm run apply-patches
57
- npm run prebuild -- --strip --all --arch x64
58
- prebuild-windows:
59
- name: Prebuild Binaries for Windows x64
60
- runs-on: windows-latest
61
- timeout-minutes: 30
62
- steps:
63
- - uses: actions/setup-node@v4
64
- with:
65
- node-version: 20.x
66
- - uses: actions/checkout@v4
67
- - run: npm i
68
- - name: Prebuild
69
- run: |
70
- npm run apply-patches
71
- npm run prebuild -- --strip --all --arch x64
72
- prebuild-windows-32:
73
- name: Prebuild Binaries for Windows ia32
74
- runs-on: windows-latest
75
- timeout-minutes: 30
76
- steps:
77
- - uses: actions/setup-node@v4
78
- with:
79
- node-version: 20.x
80
- - uses: actions/checkout@v4
81
- - run: npm i
82
- - name: Prebuild
83
- run: |
84
- npm run apply-patches
85
- npm run prebuild -- --strip --all --arch ia32
@@ -1,18 +0,0 @@
1
- name: Publish Package to npmjs
2
- on:
3
- release:
4
- types: [published]
5
- workflow_dispatch:
6
- jobs:
7
- build:
8
- runs-on: ubuntu-latest
9
- steps:
10
- - uses: actions/setup-node@v4
11
- with:
12
- node-version: 20.x
13
- registry-url: 'https://registry.npmjs.org'
14
- - uses: actions/checkout@v4
15
- - run: npm ci --ignore-scripts
16
- - run: npm publish --access public
17
- env:
18
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/ChangeLog DELETED
@@ -1,36 +0,0 @@
1
- 2016.09.10, version 0.2.2
2
- * correct memory leak (thanks to @kjlaw89)
3
-
4
- 2015.10.22, version 0.2.1
5
- * corrected printDirect with buffer data for node v4.X (#95)
6
- * corrected segmentation fault from get default printer for node v0.10.X
7
-
8
- 2015.09, version 0.2.0
9
- * added possibility to compile with node v4.X
10
- * various bug/core dumps fix
11
-
12
- 2015.04, version 0.1.2
13
- * posix: new method getPrinterDriverOptions(printerName) to retrieve PPD options
14
- * posix: new method getSelectedPaperSize(printerName) to retrieve the current paper size name
15
- * posix: new parameter `options` added to `printDirect` to set printer options (ex. `fit-to-page`, `media`, etc)
16
- * posix: new function printFile() to print a file
17
-
18
- 2015.03.03, version 0.1.1
19
- * possibility to build for node-webkit with grunt
20
-
21
- 2015.02.26, version 0.1.0
22
- * possibility to load native module for platform/arch: node_module_{platform}_{arch}.node
23
-
24
- 2015.02.24, Version 0.0.5
25
- * added getDefaultPrinterName() method by returning the default printer name
26
- * make printer argument optional in getPrinter() and printDirect. If is missing, will try to print to default printer
27
- * resolve charest of getPrinter() #38
28
- * posix/win32: added more explicit errors
29
- * posix: do not throw error if job status code is not supported
30
-
31
- 2015.01.30, Version 0.0.4
32
- * win: added RPC installed printers in getPrinters #40
33
- * posix: on some devices not all formats are supported, issue #23
34
- * posix: added link settings on build #28
35
- * corrected README.md
36
- * corrected examples
@@ -1,34 +0,0 @@
1
- var printer = require("../lib"),
2
- util = require('util'),
3
- printerName = 'Foxit Reader PDF Printer',
4
- printerFormat = 'TEXT';
5
-
6
- printer.printDirect({
7
- data:"print from Node.JS buffer", // or simple String: "some text"
8
- printer:printerName, // printer name
9
- type: printerFormat, // type: RAW, TEXT, PDF, JPEG, .. depends on platform
10
- options: // supported page sizes may be retrieved using getPrinterDriverOptions, supports CUPS printing options
11
- {
12
- media: 'Letter',
13
- 'fit-to-page': true
14
- },
15
- success:function(jobID){
16
- console.log("sent to printer with ID: "+jobID);
17
- var jobInfo = printer.getJob(printerName, jobID);
18
- console.log("current job info:"+util.inspect(jobInfo, {depth: 10, colors:true}));
19
- if(jobInfo.status.indexOf('PRINTED') !== -1)
20
- {
21
- console.log('too late, already printed');
22
- return;
23
- }
24
- console.log('cancelling...');
25
- var is_ok = printer.setJob(printerName, jobID, 'CANCEL');
26
- console.log("cancelled: "+is_ok);
27
- try{
28
- console.log("current job info:"+util.inspect(printer.getJob(printerName, jobID), {depth: 10, colors:true}));
29
- }catch(err){
30
- console.log('job deleted. err:'+err);
31
- }
32
- },
33
- error:function(err){console.log(err);}
34
- });
@@ -1,15 +0,0 @@
1
- var printer = require("../lib")
2
- , template = "N\nS4\nD15\nq400\nR\nB20,10,0,1,2,30,173,B,\"barcode\"\nP0\n";
3
-
4
- function printZebra(barcode_text, printer_name){
5
- printer.printDirect({data:template.replace(/barcode/, barcode_text)
6
- , printer:printer_name
7
- , type: "RAW"
8
- , success:function(){
9
- console.log("printed: "+barcode_text);
10
- }
11
- , error:function(err){console.log(err);}
12
- });
13
- }
14
-
15
- printZebra("123", "ZEBRA");
@@ -1,4 +0,0 @@
1
- var printer = require("../lib");
2
-
3
- console.log('default printer name: ' + (printer.getDefaultPrinterName() || 'is not defined on your computer'));
4
-
@@ -1,9 +0,0 @@
1
- var printer = require("../lib"),
2
- util = require('util'),
3
- printers = printer.getPrinters();
4
-
5
- printers.forEach(function(iPrinter, i){
6
- console.log('' + i + 'ppd for printer "' + iPrinter.name + '":' + util.inspect(printer.getPrinterDriverOptions(iPrinter.name), {colors:true, depth:10} ));
7
- console.log('\tselected page size:'+ printer.getSelectedPaperSize(iPrinter.name) + '\n');
8
- });
9
-
@@ -1,3 +0,0 @@
1
- var printer = require("../lib"),
2
- util = require('util');
3
- console.log("installed printers:\n"+util.inspect(printer.getPrinters(), {colors:true, depth:10}));
@@ -1,3 +0,0 @@
1
- var printer = require("../lib"),
2
- util = require('util');
3
- console.log("supported formats are:\n"+util.inspect(printer.getSupportedPrintFormats(), {colors:true, depth:10}));
@@ -1,3 +0,0 @@
1
- var printer = require("../lib"), //=require('pritner')
2
- util = require('util');
3
- console.log("supported job commands:\n"+util.inspect(printer.getSupportedJobCommands(), {colors:true, depth:10}));
@@ -1,30 +0,0 @@
1
- // use: node printFile.js [filePath printerName]
2
- var printer = require("../lib"),
3
- filename = process.argv[2] || __filename;
4
-
5
- console.log('platform:', process.platform);
6
- console.log('try to print file: ' + filename);
7
-
8
- if( process.platform != 'win32') {
9
- printer.printFile({filename:filename,
10
- printer: process.env[3], // printer name, if missing then will print to default printer
11
- success:function(jobID){
12
- console.log("sent to printer with ID: "+jobID);
13
- },
14
- error:function(err){
15
- console.log(err);
16
- }
17
- });
18
- } else {
19
- // not yet implemented, use printDirect and text
20
- var fs = require('fs');
21
- printer.printDirect({data:fs.readFileSync(filename),
22
- printer: process.env[3], // printer name, if missing then will print to default printer
23
- success:function(jobID){
24
- console.log("sent to printer with ID: "+jobID);
25
- },
26
- error:function(err){
27
- console.log(err);
28
- }
29
- });
30
- }
@@ -1,37 +0,0 @@
1
- // Windows does not support PDF formats, but you can use imagemagick-native to achieve conversion from PDF to EMF.
2
-
3
- var printer = require("../lib"),
4
- fs = require('fs'),
5
- path = require('path'),
6
- filename = process.argv[2],
7
- printername = process.argv[3];
8
-
9
- if(process.platform == 'win32') {
10
- throw 'Not yet supported for win32'
11
- }
12
-
13
- if(!filename || filename == '-h') {
14
- throw 'PDF file name is missing. Please use the following params: <filename> [printername]'
15
- }
16
-
17
- filename = path.resolve(process.cwd(), filename);
18
- console.log('printing file name ' + filename);
19
-
20
- fs.readFile(filename, function(err, data){
21
- if(err) {
22
- console.error('err:' + err);
23
- return;
24
- }
25
- console.log('data type is: '+typeof(data) + ', is buffer: ' + Buffer.isBuffer(data));
26
- printer.printDirect({
27
- data: data,
28
- type: 'PDF',
29
- success: function(id) {
30
- console.log('printed with id ' + id);
31
- },
32
- error: function(err) {
33
- console.error('error on printing: ' + err);
34
- }
35
- })
36
- });
37
-
@@ -1,52 +0,0 @@
1
- // Windows does not support PDF formats, but you can use imagemagick-native to achieve conversion from PDF to EMF.
2
-
3
- var printer = require("../lib"),
4
- imagemagick, // will be loaded later with proper error.
5
- fs = require('fs'),
6
- filename = process.argv[2],
7
- printername = process.argv[2];
8
-
9
- if(process.platform !== 'win32') {
10
- throw 'This application can be run only on win32 as a demo of print PDF image'
11
- }
12
-
13
- if(!filename) {
14
- throw 'PDF file name is missing. Please use the following params: <filename> [printername]'
15
- }
16
-
17
- try {
18
- imagemagick = require('imagemagick-native');
19
- } catch(e) {
20
- throw 'please install imagemagick-native: `npm install imagemagick-native`'
21
- }
22
-
23
- var data = fs.readFileSync(filename);
24
-
25
- console.log('data: ' + data.toString().substr(0, 20));
26
-
27
- //console.log(imagemagick.identify({srcData: data}));
28
-
29
- // First convert PDF into
30
- imagemagick.convert({
31
- srcData: data,
32
- srcFormat: 'PDF',
33
- format: 'EMF',
34
- }, function(err, buffer) {
35
- if (err) {
36
- throw 'something went wrong on converting to EMF: ' + err;
37
- }
38
-
39
- // Now we have EMF file, send it to printer as EMF format
40
- printer.printDirect({
41
- data: buffer,
42
- type: 'EMF',
43
- success: function(id) {
44
- console.log('printed with id ' + id);
45
- },
46
- error: function(err) {
47
- console.error('error on printing: ' + err);
48
- }
49
- })
50
- })
51
-
52
-
@@ -1,10 +0,0 @@
1
- var printer = require("../lib");
2
-
3
- printer.printDirect({data:"print from Node.JS buffer" // or simple String: "some text"
4
- //, printer:'Foxit Reader PDF Printer' // printer name, if missing then will print to default printer
5
- , type: 'RAW' // type: RAW, TEXT, PDF, JPEG, .. depends on platform
6
- , success:function(jobID){
7
- console.log("sent to printer with ID: "+jobID);
8
- }
9
- , error:function(err){console.log(err);}
10
- });
package/examples/test.pdf DELETED
Binary file
@@ -1,14 +0,0 @@
1
- exports.testLoadLibrary = function(test) {
2
- test.doesNotThrow(function(){
3
- printer = require("../");
4
- });
5
- test.done();
6
- }
7
-
8
- exports.testGetprinters = function(test) {
9
- printer = require("../");
10
- test.equal(typeof(printer.getPrinters()), 'object');
11
- test.done();
12
- }
13
-
14
- // TODO: add more tests
package/tsconfig.json DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "lib": [
5
- "es6"
6
- ],
7
- "noImplicitAny": true,
8
- "noImplicitThis": true,
9
- "strictFunctionTypes": true,
10
- "strictNullChecks": true,
11
- "baseUrl": "../",
12
- "typeRoots": [
13
- "../"
14
- ],
15
- "types": [],
16
- "noEmit": true,
17
- "forceConsistentCasingInFileNames": true
18
- },
19
- "files": [
20
- "types/index.d.ts",
21
- ]
22
- }