├── .gitignore
├── README.md
├── assets
├── all.icns
├── all.ico
└── all.png
├── auto-update.js
├── command.js
├── escpos.js
├── example.js
├── index.html
├── node_modules
├── .bin
│ ├── build.cmd
│ ├── dircompare.cmd
│ ├── run.cmd
│ ├── semver.cmd
│ ├── sshpk-conv.cmd
│ ├── sshpk-sign.cmd
│ ├── sshpk-verify.cmd
│ └── uuid.cmd
└── printer
│ ├── .npmignore
│ ├── .travis.yml
│ ├── ChangeLog
│ ├── Gruntfile.js
│ ├── README.md
│ ├── appveyor.yml
│ ├── binding.gyp
│ ├── build
│ ├── Release
│ │ ├── node_printer.exp
│ │ ├── node_printer.lib
│ │ ├── node_printer.node
│ │ ├── node_printer.pdb
│ │ └── obj
│ │ │ └── node_printer
│ │ │ ├── node_printer.obj
│ │ │ ├── node_printer.tlog
│ │ │ ├── CL.command.1.tlog
│ │ │ ├── CL.read.1.tlog
│ │ │ ├── link.command.1.tlog
│ │ │ ├── link.read.1.tlog
│ │ │ ├── link.write.1.tlog
│ │ │ ├── node_printer.lastbuildstate
│ │ │ └── node_printer.write.1u.tlog
│ │ │ ├── node_printer_win.obj
│ │ │ └── win_delay_load_hook.obj
│ ├── binding.sln
│ ├── config.gypi
│ ├── node_printer.vcxproj
│ └── node_printer.vcxproj.filters
│ ├── examples
│ ├── cancelJob.js
│ ├── example_zebra_printer.js
│ ├── getDefaultPrinterName.js
│ ├── getPrinterDriverOptions.js
│ ├── getPrinters.js
│ ├── getSupportedFormats.js
│ ├── getSupportedJobCommands.js
│ ├── printFile.js
│ ├── printPDFFileInBuffer.js
│ ├── printPDFInWindows.js
│ ├── print_raw.js
│ └── test.pdf
│ ├── lib
│ ├── index.js
│ └── printer.js
│ ├── package.json
│ ├── printer.js
│ ├── src
│ ├── macros.hh
│ ├── node_printer.cc
│ ├── node_printer.hpp
│ ├── node_printer_posix.cc
│ └── node_printer_win.cc
│ └── tools
│ └── getSourceFiles.py
├── package-lock.json
├── package.json
└── printer.js
/.gitignore:
--------------------------------------------------------------------------------
1 | /dist
2 | /node_modules
3 | .DS_Store
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | **注:仅支持`windows`系统**
2 |
3 | ## 1. 本地运行项目
4 |
5 | 使用 `npm install` 安装package.json中除了print之外的其他安装包
6 |
7 | 执行 `npm start`,首次运行会比较慢
8 | ```
9 | npm install
10 | npm start
11 | ```
12 |
13 | ## 2. 打包
14 |
15 | 使用 `nwjs-builder-phoenix` 打包,目前只生成windows版本
16 | ```
17 | npm run dist
18 | ```
19 |
20 | ## 3. 自动更新
21 |
22 | 需要在服务器上上传新的package.json和zip包
23 |
24 |
25 | ## 4. 目录结构
26 | ```
27 | |-- assets ------------- logo文件
28 | |-- node_modules ------- 依赖包,除了普通的npm install之外,对printer做了特殊处理
29 | |-- auto-update.js ----- 自动更新相关代码
30 | |-- command.js --------- esc/pos常用指令集
31 | |-- escpos.js ---------- 常用打印函数的封装
32 | |-- example.js --------- 调用打印小票样例
33 | |-- index.html --------- 主文件
34 | |-- printer.js --------- 打印机函数的封装
35 | |-- package.json
36 | ```
37 |
38 | ## 5. 整个项目遇到的难点、问题
39 |
40 | ### 1. `打包`相关
41 | 使用`nwjs-builder-phoenix`
42 |
43 | #### 问题:打开app巨慢
44 | - 原因:package.json中build:packed字段写成了true,打包时会将应用文件打包到exe中,导致每次运行exe文件都需要先解压再运行
45 | - 解决:改成false,将文件释放到exe并行目录中
46 |
47 |
48 | ### 2. `自动更新`相关
49 |
50 | > 1. 从现在运行的程序(旧版本)中检查版本清单
51 | > 2. 如果有高版本,将新包的zip文件下载到临时目录
52 | > 3. 解压zip包
53 | > 4. 在临时目录中运行新app并杀掉旧app进程
54 | > 5. 新app将会将自己复制到原始文件夹, 覆盖旧的应用程序
55 | > 6. 新应用程序将从原始文件夹中运行并退出进程
56 |
57 | #### 问题:使用中文名的productName,解压缩包时会中文乱码
58 |
59 | - 原因:`nwjs-autoupdater`可能对中文支持不友好
60 | - 解决:使用`node-webkit-updater`来自动更新
61 |
62 | #### 问题:使用`node-webkit-updater`官方例子自动更新时,在执行到替换旧版本时会报错 `EBUSY: resource busy or locked`
63 |
64 | - 原因:在运行安装程序时的步骤4中, 它的 cwd 默认为当前进程的 cwd, 可能是旧应用程序的目录。所以, 无法删除、覆盖安装目标目录, 因为正在使用它。
65 | - 解决:在源代码中添加 const newAppDir = path.dirname(newAppPath),再将 upd.runInstaller(newAppPath, [upd.getAppPath(), upd.getAppExec()],{}) 改为 upd.runInstaller(newAppPath, [upd.getAppPath(), upd.getAppExec()], {cwd: newAppDir} )
66 |
67 |
68 | ### 3. `打印`相关
69 |
70 | #### 问题:printer环境配置
71 |
72 | - 原因:printer本质属于c++插件,需要特殊配置
73 | - 解决:安装python2.7版本,执行下面命令
74 | ```bash
75 | npm install printer --target_arch=x64
76 | cd node_modules/printer
77 | nw-gyp configure --target=${nw-version}
78 | nw-gyp rebuild --target=${nw-version}
79 | ```
80 |
81 |
82 | #### 问题:不能打印汉字
83 |
84 | - 原因:node的buffer不支持gbk编码
85 | - 解决:使用iconv-lite进行bgk编码
86 |
87 | #### 问题:多列布局实现
88 |
89 | - 原因:不知道什么方式实现类似flex布局
90 | - 解决:使用sprint-js,一个神奇的补空格实现布局的方案
91 |
92 | #### 问题:分割线实现
93 |
94 | - 原因:没有分割线指令
95 | - 解决:结合sprint-js,用一行带下划线的空格来模拟
96 |
97 | #### 问题:切纸
98 |
99 | - 原因:一开始尝试的全切,当连续多张打印时,前面的纸会卡住后面的纸
100 | - 解决:改用留点半切
101 |
102 |
103 | 参考文献
104 |
105 | [微型热敏打印机指令集](https://wenku.baidu.com/view/6de8b8fec281e53a5902ff98#1?qq-pf-to=pcqq.c2c)
--------------------------------------------------------------------------------
/assets/all.icns:
--------------------------------------------------------------------------------
1 | icns
--------------------------------------------------------------------------------
/assets/all.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LittlehorseXie/nw-printer/ae517fa3a450ef8c591c09d28db3cf32f7396cdd/assets/all.ico
--------------------------------------------------------------------------------
/assets/all.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LittlehorseXie/nw-printer/ae517fa3a450ef8c591c09d28db3cf32f7396cdd/assets/all.png
--------------------------------------------------------------------------------
/auto-update.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 自动更新
3 | */
4 |
5 | const output = document.querySelector( "#output" )
6 | const gui = require('nw.gui') //操作nw应用
7 | const updater = require('node-webkit-updater') //热更新
8 | const pkg = require('./package.json')
9 | const upd = new updater(pkg)
10 | const path = require('path')
11 | let copyPath = '', execPath = ''
12 | let progressTimer = null //设置一个定时器,用来模拟下载的进去条
13 |
14 | if (gui.App.argv.length) {
15 | copyPath = gui.App.argv[0]
16 | execPath = gui.App.argv[1]
17 | console.log('替换旧版本')
18 | output.innerHTML = copyPath + ' 替换旧版本 ' + execPath
19 | // 替换旧版本
20 | upd.install(copyPath, function(err) {
21 | if (!err) {
22 | // 重启
23 | output.innerHTML = '重启 ' + execPath
24 | upd.run(execPath, null)
25 | gui.App.quit()
26 | } else {
27 | output.innerHTML = err
28 | }
29 | })
30 | } else {
31 | // 从manifest目录校验版本
32 | console.log('从manifest目录校验版本')
33 | output.innerHTML = '从manifest目录校验版本'
34 | upd.checkNewVersion(function(error, newVersionExists, manifest) {
35 | console.log(error, newVersionExists, manifest)
36 | if (!error && newVersionExists && confirm('检测到新版本,您需要升级吗?')) {
37 | // 有新版本显示下载进度条开始下载
38 | console.log('有新版本显示下载进度条开始下载')
39 | output.innerHTML = '有新版本显示下载进度条开始下载'
40 | setTimeout(function() {
41 | let startC = parseInt(Math.floor(Math.random() + 1) * 3)
42 | progressTimer = setInterval(function() {
43 | startC += Math.random() * 2
44 | if (startC >= 95) {
45 | clearInterval(progressTimer)
46 | startC = 95
47 | }
48 | console.log(startC.toFixed(2) + '%')
49 | output.innerHTML = startC.toFixed(2) + '%'
50 | }, 2000)
51 | }, 1000)
52 |
53 | // 下载新版本
54 | console.log('下载新版本')
55 | output.innerHTML = '下载新版本'
56 | upd.download(function(error, filename) {
57 | console.log(error, filename)
58 | if (!error) {
59 | clearInterval(progressTimer)
60 | // 下载完成关闭应用
61 | console.log('下载完成即将关闭应用')
62 | output.innerHTML = '下载完成即将关闭应用'
63 | upd.unpack(filename, function(error, newAppPath) {
64 | console.log(error, newAppPath)
65 | if (!error) {
66 | const newAppDir = path.dirname(newAppPath)
67 | console.log('重启应用')
68 | output.innerHTML = '重启应用'
69 | console.log(newAppPath, [upd.getAppPath(), upd.getAppExec()])
70 | // 重启应用
71 | output.innerHTML = `${newAppPath}, [${upd.getAppPath()}, ${upd.getAppExec()}, cwd: ${newAppDir}]`
72 | upd.runInstaller(newAppPath, [upd.getAppPath(), upd.getAppExec()], {cwd: newAppDir})
73 | gui.App.quit()
74 | }
75 | }, manifest)
76 | }
77 | }, manifest)
78 | } else if (!error && !newVersionExists) {
79 | console.log('您已经是最新版本')
80 | }
81 | })
82 | }
--------------------------------------------------------------------------------
/command.js:
--------------------------------------------------------------------------------
1 | const ESC = 0x1B,
2 | FS = 0x1C,
3 | GS = 0x1D
4 |
5 | const Command = {
6 |
7 | LF : [0x0A], // 打印并走纸
8 | ESC_init : [ESC, 0x40], // 初始化打印机 ESC @
9 |
10 | ESC_exclamation : (n) => [ESC, 0x21, n], // ESC!n
11 | ESC_minus : (n) => [ESC, 0x2D, n], // 下划线0关闭,1开启1点宽,2开启2点宽
12 | ESC_rev : (n) => [ESC, 0x7B, n], // 设置0/取消1反向打印 ESC{n
13 | ESC_3 : (n) => [ESC, 0x33, n], // 设置字符行间距
14 | ESC_a : (n) => [ESC, 0x61, n], // 对齐模式0,48左/1,49中/2,50右
15 | ESC_d : (n) => [ESC, 0x64, n], // 打印并进纸n行
16 | ESC_e : (n) => [ESC, 0x65, n], // 打印并反向进纸n行
17 | ESC_E : (n) => [ESC, 0x45, n], // 设置1/取消0加粗模式
18 | ESC_G : (n) => [ESC, 0x47, n], // 设置1/取消0加重模式
19 | ESC_J : (n) => [ESC, 0x4A, n], // 打印并走纸n行
20 |
21 | FS_and : [FS, 0x26], // 进入汉字打印模式
22 |
23 | GS_exclamation : (n) => [GS, 0x21, n], // 字体放大 GS!n
24 | GS_B : (n) => [GS, 0x42, n], // 设置字符黑、白反转打印模式
25 | GS_h : (n) => [GS, 0x68, n], // 设置条码高度
26 | GS_v0 : (m) => [GS, 0x76, 0x30, m], // 打印点图数据
27 | GS_w : (n) => [GS, 0x77, n], // 设置条码宽度
28 | GS_W : (m, n) => [GS, 0x57, m, n], // 设置打印区宽度
29 | GS_V : (m) => [GS, 0x56, m], // 切纸 48全切 49六点半切
30 |
31 |
32 |
33 | }
34 |
35 |
36 | module.exports = Command
--------------------------------------------------------------------------------
/escpos.js:
--------------------------------------------------------------------------------
1 | const Command = require('./command')
2 | const iconv = require('iconv-lite')
3 | const sprintf = require('sprintf-js').sprintf
4 | const MutableBuffer = require('mutable-buffer').MutableBuffer
5 | const middleCharLen = 22
6 |
7 | function getChnCount(str) {
8 | return str.replace(/[\u0391-\uFFE5]/g, 'aa').length - str.length
9 | }
10 |
11 | const Buffer = function() {
12 | this._buf = new MutableBuffer()
13 | this._buf.write(Command.ESC_init)
14 | }
15 |
16 | Buffer.prototype = {
17 | /**
18 | * 打印文字
19 | * @function setThreeCol 设置左中右布局
20 | * @param {string, string, string}
21 | * @function setTwoCol 设置左右布局
22 | * @param {string, string}
23 | * @function setDecLine 分割线
24 | * @param {}
25 | * @function setBoldOn 开启粗体模式
26 | * @param {}
27 | * @function setBoldOff 关闭粗体模式
28 | * @param {}
29 | * @function setLineHeight 设置字行高
30 | * @param {number}
31 | * @function setLine 换行并打印
32 | * @param {number}
33 | * @function setText 写文字
34 | * @param {string}
35 | * @function setTextDirection 设置文字布局
36 | * @param {string}
37 | * @function setTextSize 设置字体大小
38 | * @param {number}
39 | * @function cut 留点切纸
40 | * @param {}
41 | * @function getBuffer 获取字符
42 | * @param {}
43 | */
44 | setThreeColText: function (l, m, r) {
45 | const chnLen = getChnCount(m)
46 | const buf = sprintf(`%3s %-${middleCharLen-chnLen}s %8s`, l, m, r)
47 | this._buf.write(iconv.encode(buf,'GBK'))
48 | this._buf.write(Command.LF)
49 | },
50 | setThreeCol: function (first, second, third) {
51 | const chnLen = getChnCount(second)
52 | const charLen = second.length + chnLen
53 | // console.log(charLen, middleCharLen)
54 | if (charLen <= middleCharLen) {
55 | this.setThreeColText(first, second, third)
56 | } else {
57 | let charList = [2]
58 | for (let i = 1; i < second.length; i++) {
59 | const charCode = second.charCodeAt(i)
60 | if (charCode >= 0 && charCode <= 128) {
61 | charList.push(1 + charList[i - 1])
62 | } else {
63 | charList.push(2 + charList[i - 1])
64 | }
65 | }
66 | let indexList = [0]
67 | for (let i = 10; i < charList.length; i++) {
68 | if(charList[i] % 22 >= 0 && charList[i] % 22 < 2 && !(charList[i+1] && charList[i+1] % 22 >= 0 && charList[i+1] % 22 < 2)) {
69 | indexList.push(i)
70 | }
71 | }
72 | this.setThreeColText(first, second.slice(0, indexList[1]), third)
73 | // console.log(second.slice(0, indexList[1]))
74 | if (indexList.length === 2) {
75 | this.setThreeColText('', second.slice(indexList[1]), '')
76 | // console.log(second.slice(indexList[1]))
77 | } else {
78 | for(let i = 2; i < indexList.length; i++) {
79 | if (i === indexList.length - 1) {
80 | this.setThreeColText('', second.slice(indexList[i]), '')
81 | // console.log(second.slice(indexList[i]))
82 | } else {
83 | this.setThreeColText('', second.slice(indexList[i - 1], indexList[i]), '')
84 | // console.log(second.slice(indexList[i - 1], indexList[i]))
85 | }
86 | }
87 | }
88 | }
89 | return this
90 | },
91 | setTwoCol: function (one, two) {
92 | const buf = sprintf(`%-${30-one.length}s%8s`, one, two)
93 | this._buf.write(iconv.encode(buf,'GBK'))
94 | this._buf.write(Command.LF)
95 | return this
96 | },
97 | setDecLine: function () {
98 | this._buf.write(Command.ESC_minus(2))
99 | this._buf.write(sprintf(`%40s`, ' '))
100 | this._buf.write(Command.ESC_minus(0))
101 | this._buf.write(sprintf(`%40s`, ' '))
102 | this._buf.write(Command.LF)
103 | return this
104 | },
105 | setBoldOn: function () {
106 | this._buf.write(Command.ESC_E(1))
107 | return this
108 | },
109 | setBoldOff: function () {
110 | this._buf.write(Command.ESC_E(0))
111 | return this
112 | },
113 | setLineHeight: function (num) {
114 | this._buf.write(Command.ESC_3(num))
115 | return this
116 | },
117 | setLine: function (n) {
118 | if (!n) {
119 | this._buf.write(Command.LF)
120 | return this
121 | }
122 | this._buf.write(Command.ESC_d(n))
123 | return this
124 | },
125 | setText: function (str, direction) {
126 | if (direction && direction === 'center') {
127 | this._buf.write(Command.ESC_a(49))
128 | this._buf.write(iconv.encode(str,'GBK'))
129 | } else if(direction && direction === 'right') {
130 | this._buf.write(Command.ESC_a(50))
131 | this._buf.write(iconv.encode(str,'GBK'))
132 | } else {
133 | this._buf.write(Command.ESC_a(48))
134 | this._buf.write(iconv.encode(str,'GBK'))
135 | }
136 | this._buf.write(Command.LF)
137 | return this
138 | },
139 | setTextDirection: function(direction) {
140 | if (direction && direction === 'center') {
141 | this._buf.write(Command.ESC_a(49))
142 | } else if(direction && direction === 'right') {
143 | this._buf.write(Command.ESC_a(50))
144 | } else {
145 | this._buf.write(Command.ESC_a(48))
146 | }
147 | return this
148 | },
149 | setTextSize: function (n) {
150 | switch(n) {
151 | case 2:
152 | this._buf.write(Command.GS_exclamation(17))
153 | break
154 | default:
155 | this._buf.write(Command.GS_exclamation(0))
156 | }
157 | return this
158 | },
159 | cut: function() {
160 | this._buf.write(Command.GS_V(49))
161 | return this
162 | },
163 | getBuffer: function() {
164 | this._buf.flush()
165 | return this._buf.buffer
166 | }
167 | }
168 |
169 | module.exports = Buffer
--------------------------------------------------------------------------------
/example.js:
--------------------------------------------------------------------------------
1 | const printer = require('./printer.js')
2 |
3 | const mockData = {
4 | id: 001,
5 | delivery_way: '外送',
6 | deliver_time: '立即送达',
7 | sku_detail: [{
8 | quantity: 10,
9 | sku_name: '火米饼套餐',
10 | price: 20
11 | }],
12 | description: '多放火贝 火火火火',
13 | invoiced: '',
14 | package_fee: 1,
15 | deliver_fee: 10,
16 | total_price: 31,
17 | receiver_address: '火星1区101路1号',
18 | receiver_name: '火星人',
19 | receiver_phone: 00001,
20 | create_time: '0001-01-01',
21 | tagg_shop_name: '火星1号商店'
22 | }
23 |
24 | function getPrinterList() {
25 | const list = printer.getPrinterList()
26 | const res = []
27 | list.forEach(item => res.push(item.name))
28 | return res
29 | }
30 |
31 | function getPrinter(name) {
32 | return printer.getPrinter(name)
33 | }
34 |
35 | function printOrderRecive(name = '', data = {}) {
36 | console.log(name, data)
37 | const Buffer = require('./escpos.js')
38 | let buffer = new Buffer()
39 |
40 | buffer = buffer.setLineHeight(70)
41 | .setTextSize(2).setLineHeight(50).setText(data.id, 'center')
42 | .setTextSize(1).setLineHeight(100).setText(`${data.delivery_way} ${data.deliver_time}`, 'center')
43 | .setLineHeight(70).setDecLine()
44 | .setBoldOn()
45 | .setLineHeight(70)
46 | data.sku_detail && data.sku_detail.forEach(item => {
47 | buffer = buffer.setThreeCol(item.quantity, item.sku_name, `¥${item.price}`)
48 | })
49 | buffer = buffer.setLine()
50 | .setLineHeight(100).setText(`备注:${data.description}`).setBoldOff()
51 | .setLineHeight(50).setDecLine()
52 | .setLineHeight(70)
53 | .setTwoCol('开具发票', data.invoiced)
54 | .setTwoCol('包装费', `¥${data.package_fee}`)
55 | .setTwoCol('配送费', `¥${data.deliver_fee}`)
56 | .setLineHeight(50)
57 | .setDecLine()
58 | .setBoldOn().setText(`合计:¥${data.total_price} `, 'right').setBoldOff()
59 | .setDecLine()
60 | .setLineHeight(70)
61 | .setText(`送货地址:${data.receiver_address}`)
62 | .setText(`客户:${data.receiver_name} ${data.receiver_phone}`)
63 | .setDecLine()
64 | .setText(`下单时间: ${data.create_time}`, 'center')
65 | .setLine(2)
66 | .setBoldOn().setText(`${data.tagg_shop_name} \n \n`, 'center').setBoldOff()
67 | .setLine(2)
68 | .cut()
69 | .getBuffer()
70 |
71 | printer.print(name, buffer)
72 | }
73 |
74 | module.exports = {
75 | mockData,
76 | getPrinterList,
77 | getPrinter,
78 | printOrderRecive
79 | }
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 万象集
6 |
18 |
19 |
20 |
21 |
22 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/node_modules/.bin/build.cmd:
--------------------------------------------------------------------------------
1 | @IF EXIST "%~dp0\node.exe" (
2 | "%~dp0\node.exe" "%~dp0\..\nwjs-builder-phoenix\dist\bin\build.js" %*
3 | ) ELSE (
4 | @SETLOCAL
5 | @SET PATHEXT=%PATHEXT:;.JS;=;%
6 | node "%~dp0\..\nwjs-builder-phoenix\dist\bin\build.js" %*
7 | )
--------------------------------------------------------------------------------
/node_modules/.bin/dircompare.cmd:
--------------------------------------------------------------------------------
1 | @IF EXIST "%~dp0\node.exe" (
2 | "%~dp0\node.exe" "%~dp0\..\dir-compare\dircompare.js" %*
3 | ) ELSE (
4 | @SETLOCAL
5 | @SET PATHEXT=%PATHEXT:;.JS;=;%
6 | node "%~dp0\..\dir-compare\dircompare.js" %*
7 | )
--------------------------------------------------------------------------------
/node_modules/.bin/run.cmd:
--------------------------------------------------------------------------------
1 | @IF EXIST "%~dp0\node.exe" (
2 | "%~dp0\node.exe" "%~dp0\..\nwjs-builder-phoenix\dist\bin\run.js" %*
3 | ) ELSE (
4 | @SETLOCAL
5 | @SET PATHEXT=%PATHEXT:;.JS;=;%
6 | node "%~dp0\..\nwjs-builder-phoenix\dist\bin\run.js" %*
7 | )
--------------------------------------------------------------------------------
/node_modules/.bin/semver.cmd:
--------------------------------------------------------------------------------
1 | @IF EXIST "%~dp0\node.exe" (
2 | "%~dp0\node.exe" "%~dp0\..\semver\bin\semver" %*
3 | ) ELSE (
4 | @SETLOCAL
5 | @SET PATHEXT=%PATHEXT:;.JS;=;%
6 | node "%~dp0\..\semver\bin\semver" %*
7 | )
--------------------------------------------------------------------------------
/node_modules/.bin/sshpk-conv.cmd:
--------------------------------------------------------------------------------
1 | @IF EXIST "%~dp0\node.exe" (
2 | "%~dp0\node.exe" "%~dp0\..\sshpk\bin\sshpk-conv" %*
3 | ) ELSE (
4 | @SETLOCAL
5 | @SET PATHEXT=%PATHEXT:;.JS;=;%
6 | node "%~dp0\..\sshpk\bin\sshpk-conv" %*
7 | )
--------------------------------------------------------------------------------
/node_modules/.bin/sshpk-sign.cmd:
--------------------------------------------------------------------------------
1 | @IF EXIST "%~dp0\node.exe" (
2 | "%~dp0\node.exe" "%~dp0\..\sshpk\bin\sshpk-sign" %*
3 | ) ELSE (
4 | @SETLOCAL
5 | @SET PATHEXT=%PATHEXT:;.JS;=;%
6 | node "%~dp0\..\sshpk\bin\sshpk-sign" %*
7 | )
--------------------------------------------------------------------------------
/node_modules/.bin/sshpk-verify.cmd:
--------------------------------------------------------------------------------
1 | @IF EXIST "%~dp0\node.exe" (
2 | "%~dp0\node.exe" "%~dp0\..\sshpk\bin\sshpk-verify" %*
3 | ) ELSE (
4 | @SETLOCAL
5 | @SET PATHEXT=%PATHEXT:;.JS;=;%
6 | node "%~dp0\..\sshpk\bin\sshpk-verify" %*
7 | )
--------------------------------------------------------------------------------
/node_modules/.bin/uuid.cmd:
--------------------------------------------------------------------------------
1 | @IF EXIST "%~dp0\node.exe" (
2 | "%~dp0\node.exe" "%~dp0\..\uuid\bin\uuid" %*
3 | ) ELSE (
4 | @SETLOCAL
5 | @SET PATHEXT=%PATHEXT:;.JS;=;%
6 | node "%~dp0\..\uuid\bin\uuid" %*
7 | )
--------------------------------------------------------------------------------
/node_modules/printer/.npmignore:
--------------------------------------------------------------------------------
1 | .gitignore
2 | *~
3 | .settings
4 | .c9*
5 |
--------------------------------------------------------------------------------
/node_modules/printer/.travis.yml:
--------------------------------------------------------------------------------
1 | env:
2 | matrix:
3 | - export NODE_VERSION="5.9"
4 | - export NODE_VERSION="4.4"
5 | - export NODE_VERSION="0.10"
6 | matrix:
7 | fast_finish: true
8 | allow_failures:
9 | - env: NODE_VERSION="0.10"
10 | - env: NODE_VERSION="iojs"
11 | before_install:
12 | - git clone https://github.com/creationix/nvm.git ./.nvm
13 | - source ./.nvm/nvm.sh
14 | - nvm install $NODE_VERSION
15 | - echo $NODE_VERSION
16 | - nvm use $NODE_VERSION
17 | - if [ $TRAVIS_OS_NAME == "linux" ]; then
18 | sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test;
19 | sudo apt-get -qq update;
20 | sudo apt-get -qq install g++-4.8;
21 | export CXX='g++-4.8';
22 | sudo apt-get install -qq debhelper autotools-dev cups-ppdc libcups2-dev cups imagemagick ghostscript;
23 | fi
24 | - "export JOBS=4"
25 | - BUILD_ONLY=true npm install
26 | before_script:
27 | - git config --global user.name "Ion Lupascu"
28 | - git config --global user.email ionlupascu@gmail.com
29 | git:
30 | depth: 1
31 | branches:
32 | only:
33 | - master
34 | os:
35 | - linux
36 | - osx
37 | script: npm test
38 |
--------------------------------------------------------------------------------
/node_modules/printer/ChangeLog:
--------------------------------------------------------------------------------
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
37 |
--------------------------------------------------------------------------------
/node_modules/printer/Gruntfile.js:
--------------------------------------------------------------------------------
1 | module.exports = function(grunt) {
2 | grunt.initConfig({
3 | gyp: {
4 | ia32: {
5 | command: 'rebuild',
6 | options: {
7 | arch: 'ia32'
8 | }
9 | },
10 | x64: {
11 | command: 'rebuild',
12 | options: {
13 | arch: 'x64'
14 | }
15 | }
16 | },
17 | "nw-gyp": {
18 | ia32: {
19 | command: 'rebuild',
20 | options: {
21 | arch: 'ia32'
22 | }
23 | },
24 | x64: {
25 | command: 'rebuild',
26 | options: {
27 | arch: 'x64'
28 | }
29 | }
30 | },
31 | copy: {
32 | ia32: {
33 | files: [{src: 'build/Release/node_printer.node', dest: 'lib/node_printer_' + process.platform + '_ia32.node'}]
34 | },
35 | x64: {
36 | files: [{src: 'build/Release/node_printer.node', dest: 'lib/node_printer_' + process.platform + '_x64.node'}]
37 | }
38 | }
39 | });
40 |
41 | grunt.loadNpmTasks('grunt-contrib-jshint');
42 | grunt.loadNpmTasks('grunt-node-gyp');
43 | grunt.loadNpmTasks('grunt-nw-gyp');
44 | grunt.loadNpmTasks('grunt-contrib-copy');
45 |
46 | grunt.registerTask('build-nw-ia32', [
47 | 'nw-gyp:ia32',
48 | 'copy:ia32'
49 | ]);
50 |
51 | grunt.registerTask('build-ia32', [
52 | 'gyp:ia32',
53 | 'copy:ia32'
54 | ]);
55 |
56 | grunt.registerTask('build-x64', [
57 | 'gyp:x64',
58 | 'copy:x64'
59 | ]);
60 |
61 | grunt.registerTask('build-nw-x64', [
62 | 'nw-gyp:x64',
63 | 'copy:x64'
64 | ]);
65 |
66 | grunt.registerTask('build', [
67 | 'build-ia32',
68 | 'build-x64'
69 | ]);
70 |
71 | grunt.registerTask('build-nw', [
72 | 'build-nw-ia32',
73 | 'build-nw-x64'
74 | ]);
75 | }
76 |
--------------------------------------------------------------------------------
/node_modules/printer/README.md:
--------------------------------------------------------------------------------
1 | node-printer
2 | ============
3 | Native bind printers on POSIX and Windows OS from Node.js, iojs and node-webkit.
4 |
5 |
6 |
7 | Linux |
8 | Windows |
9 | Dependencies |
10 |
11 |
12 |
13 |
14 |
15 |
16 | |
17 |
18 |
19 | |
20 |
21 |
22 | |
23 |
24 |
25 |
26 |
27 | If you have a problem, ask question to [](https://gitter.im/tojocky/node-printer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) or find/create a new [Github issue](https://github.com/tojocky/node-printer/issues)
28 |
29 | ### Reason:
30 |
31 | I was involved in a project where I need to print from Node.JS. This is the reason why I created this project and I want to share my code with others.
32 |
33 |
34 | ### Features:
35 |
36 | * no dependecies;
37 | * native method wrappers from Windows and POSIX (which uses [CUPS 1.4/MAC OS X 10.6](http://cups.org/)) APIs;
38 | * compatible with node v0.8.x, 0.9.x and v0.11.x (with 0.11.9 and 0.11.13);
39 | * compatible with node-webkit v0.8.x and 0.9.2;
40 | * `getPrinters()` to enumerate all installed printers with current jobs and statuses;
41 | * `getPrinter(printerName)` to get a specific/default printer info with current jobs and statuses;
42 | * `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
43 | * `getSelectedPaperSize(printerName)` ([POSIX](http://en.wikipedia.org/wiki/POSIX) only) to get a specific/default printer default paper size from its driver options
44 | * `getDefaultPrinterName()` return the default printer name;
45 | * `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;
46 | * `printFile(options)` ([POSIX](http://en.wikipedia.org/wiki/POSIX) only) to print a file;
47 | * `getSupportedPrintFormats()` to get all possible print formats for printDirect method which depends on OS. `RAW` and `TEXT` are supported from all OS-es;
48 | * `getJob(printerName, jobId)` to get a specific job info including job status;
49 | * `setJob(printerName, jobId, command)` to send a command to a job (e.g. `'CANCEL'` to cancel the job);
50 | * `getSupportedJobCommands()` to get supported job commands for setJob() depends on OS. `'CANCEL'` command is supported from all OS-es.
51 |
52 |
53 | ### How to install:
54 | Make sure you have Python 2.x installed on your system. Windows users will also require Visual Studio (2013 Express is a good fit)
55 |
56 | from [npmjs.org](https://www.npmjs.org/package/printer)
57 |
58 | npm install -g node-gyp
59 | npm install printer --msvs_version=2013
60 |
61 | or [direct from git](https://www.npmjs.org/doc/cli/npm-install.html):
62 |
63 | npm install git+https://github.com/tojocky/node-printer.git
64 | if you want to to run in [nwjs](http://nwjs.io/) then rebuild the module with [nw-gyp](https://github.com/nwjs/nw-gyp):
65 | ```
66 | npm install -g nw-gyp
67 | cd node_modules/printer
68 | nw-gyp rebuild
69 | ```
70 | For specific distribution `--dist-url` node-gyp parameter should be used. Example for electron:
71 | ```
72 | node-gyp rebuild --target=0.37.4 --arch=x64 --dist-url=https://atom.io/download/atom-shell
73 | ```
74 |
75 | Ubuntu User :
76 | You need to install libcups2-dev package
77 | `sudo apt-get install libcups2-dev`
78 |
79 |
80 | ### How to use:
81 |
82 | See [examples](https://github.com/tojocky/node-printer/tree/master/examples)
83 |
84 | ### Author(s):
85 |
86 | * Ion Lupascu, ionlupascu@gmail.com
87 |
88 | ### Contibutors:
89 |
90 | Feel free to download, test and propose new futures
91 |
92 | ### License:
93 | [The MIT License (MIT)](http://opensource.org/licenses/MIT)
94 |
--------------------------------------------------------------------------------
/node_modules/printer/appveyor.yml:
--------------------------------------------------------------------------------
1 | # appveyor file
2 | # http://www.appveyor.com/docs/appveyor-yml
3 |
4 | # Try out "interactive-mode"
5 | os: Windows Server 2012 R2
6 |
7 | # build version format
8 | version: "{build}"
9 |
10 | # Set a known clone folder
11 | clone_folder: c:\projects\node-printer
12 |
13 | # fix lineendings in Windows
14 | init:
15 | - git config --global core.autocrlf input
16 | - git config --global user.name "Ion Lupascu"
17 | - git config --global user.email ionlupascu@gmail.com
18 |
19 | # what combinations to test
20 | environment:
21 | matrix:
22 | # Node.js
23 | - nodejs_version: "0.10"
24 | - nodejs_version: "0.12"
25 | - nodejs_version: "4.4"
26 | - nodejs_version: "5.9"
27 |
28 | matrix:
29 | fast_finish: true
30 | allow_failures:
31 | - nodejs_version: "0.10"
32 |
33 | # Get the latest stable version of Node 0.STABLE.latest
34 | install:
35 | - ps: Install-Product node $env:nodejs_version
36 | - cmd: SET PATH=C:\Program Files (x86)\MSBuild\12.0\bin\;%PATH%
37 | - cmd: SET PATH=c:\python27;%PATH%
38 | - cmd: SET JOBS=4
39 | - cmd: SET BUILD_ONLY=true
40 | - cmd: npm install -g node-gyp
41 | - npm install --msvs_version=2013
42 |
43 | test_script:
44 | - node --version
45 | - npm --version
46 | # - cmd: npm test
47 |
48 | build: off
49 |
50 | branches:
51 | only:
52 | - master
53 |
--------------------------------------------------------------------------------
/node_modules/printer/binding.gyp:
--------------------------------------------------------------------------------
1 | {
2 | 'targets': [
3 | {
4 | 'target_name': 'node_printer',
5 | 'sources': [
6 | # is like "ls -1 src/*.cc", but gyp does not support direct patterns on
7 | # sources
8 | '
2 |
3 |
4 |
5 | Debug
6 | x64
7 |
8 |
9 | Debug
10 | x64
11 |
12 |
13 | Release
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {DEB1940F-78E4-FFEC-FD8A-00BE447D0E86}
23 | Win32Proj
24 | node_printer
25 | true
26 | x64
27 | 10.0.17763.0
28 |
29 |
30 |
31 | DynamicLibrary
32 |
33 |
34 | v141
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | $(ExecutablePath);$(MSBuildProjectDirectory)\..\bin\;$(MSBuildProjectDirectory)\..\bin\
45 | true
46 | $(Configuration)\obj\$(ProjectName)\
47 | true
48 | $(SolutionDir)$(Configuration)\
49 | .node
50 | .node
51 | .node
52 | .node
53 | .node
54 | .node
55 | .node
56 | .node
57 | $(ProjectName)
58 | $(OutDir)\$(ProjectName).node
59 |
60 |
61 |
62 | C:\Users\SF\.nw-gyp\0.32.0\include\node;C:\Users\SF\.nw-gyp\0.32.0\src;C:\Users\SF\.nw-gyp\0.32.0\deps\uv\include;C:\Users\SF\.nw-gyp\0.32.0\deps\v8\include;%(AdditionalIncludeDirectories)
63 | /bigobj /d2FastFail /Zc:sizedDealloc- /Zc:threadSafeInit- /MP %(AdditionalOptions)
64 | EnableFastChecks
65 | true
66 | false
67 | ProgramDatabase
68 | 4251;4275;4267;4351;4355;4800;4595;4251;%(DisableSpecificWarnings)
69 | false
70 | false
71 | false
72 | Disabled
73 | NotUsing
74 | NODE_GYP_MODULE_NAME=node_printer;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;BUILDING_NODE_EXTENSION;DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions)
75 | MultiThreadedDebug
76 | true
77 | true
78 | false
79 | Level3
80 |
81 |
82 | kernel32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;user32.lib;uuid.lib;odbc32.lib;odbccp32.lib;delayimp.lib;credui.lib;dbghelp.lib;shlwapi.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;"C:\Users\SF\.nw-gyp\0.32.0\x64\nw.lib";"C:\Users\SF\.nw-gyp\0.32.0\x64\node.lib"
83 | /ignore:4199 /maxilksize:0x7ff00000 /fastfail %(AdditionalOptions)
84 | true
85 | true
86 | iojs.exe;node.exe;%(DelayLoadDLLs)
87 | true
88 | false
89 | false
90 | $(OutDir)$(ProjectName).node
91 | true
92 | true
93 | .node
94 | MachineX64
95 |
96 |
97 | C:\Users\SF\.nw-gyp\0.32.0\include\node;C:\Users\SF\.nw-gyp\0.32.0\src;C:\Users\SF\.nw-gyp\0.32.0\deps\uv\include;C:\Users\SF\.nw-gyp\0.32.0\deps\v8\include;%(AdditionalIncludeDirectories)
98 | NODE_GYP_MODULE_NAME=node_printer;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;BUILDING_NODE_EXTENSION;DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions);%(PreprocessorDefinitions)
99 |
100 |
101 |
102 |
103 | C:\Users\SF\.nw-gyp\0.32.0\include\node;C:\Users\SF\.nw-gyp\0.32.0\src;C:\Users\SF\.nw-gyp\0.32.0\deps\uv\include;C:\Users\SF\.nw-gyp\0.32.0\deps\v8\include;%(AdditionalIncludeDirectories)
104 | /bigobj /d2FastFail /Zc:sizedDealloc- /Zc:threadSafeInit- /MP %(AdditionalOptions)
105 | EnableFastChecks
106 | true
107 | false
108 | ProgramDatabase
109 | 4251;4275;4267;4351;4355;4800;4595;4251;%(DisableSpecificWarnings)
110 | false
111 | false
112 | false
113 | Disabled
114 | NotUsing
115 | NODE_GYP_MODULE_NAME=node_printer;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;BUILDING_NODE_EXTENSION;DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions)
116 | MultiThreadedDebug
117 | true
118 | true
119 | false
120 | Level3
121 |
122 |
123 | kernel32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;user32.lib;uuid.lib;odbc32.lib;odbccp32.lib;delayimp.lib;credui.lib;dbghelp.lib;shlwapi.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;"C:\Users\SF\.nw-gyp\0.32.0\x64\nw.lib";"C:\Users\SF\.nw-gyp\0.32.0\x64\node.lib"
124 | /ignore:4199 /maxilksize:0x7ff00000 /fastfail %(AdditionalOptions)
125 | true
126 | true
127 | iojs.exe;node.exe;%(DelayLoadDLLs)
128 | true
129 | false
130 | false
131 | $(OutDir)$(ProjectName).node
132 | true
133 | true
134 | .node
135 | MachineX64
136 |
137 |
138 | C:\Users\SF\.nw-gyp\0.32.0\include\node;C:\Users\SF\.nw-gyp\0.32.0\src;C:\Users\SF\.nw-gyp\0.32.0\deps\uv\include;C:\Users\SF\.nw-gyp\0.32.0\deps\v8\include;%(AdditionalIncludeDirectories)
139 | NODE_GYP_MODULE_NAME=node_printer;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;BUILDING_NODE_EXTENSION;DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions);%(PreprocessorDefinitions)
140 |
141 |
142 |
143 |
144 | C:\Users\SF\.nw-gyp\0.32.0\include\node;C:\Users\SF\.nw-gyp\0.32.0\src;C:\Users\SF\.nw-gyp\0.32.0\deps\uv\include;C:\Users\SF\.nw-gyp\0.32.0\deps\v8\include;%(AdditionalIncludeDirectories)
145 | /bigobj /d2FastFail /Zc:sizedDealloc- /Zc:threadSafeInit- /MP %(AdditionalOptions)
146 | true
147 | false
148 | ProgramDatabase
149 | 4251;4275;4267;4351;4355;4800;4595;4251;%(DisableSpecificWarnings)
150 | false
151 | Speed
152 | true
153 | AnySuitable
154 | true
155 | true
156 | Full
157 | NotUsing
158 | NODE_GYP_MODULE_NAME=node_printer;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;BUILDING_NODE_EXTENSION;%(PreprocessorDefinitions)
159 | MultiThreaded
160 | false
161 | true
162 | true
163 | false
164 | Level3
165 | false
166 |
167 |
168 | kernel32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;user32.lib;uuid.lib;odbc32.lib;odbccp32.lib;delayimp.lib;credui.lib;dbghelp.lib;shlwapi.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;"C:\Users\SF\.nw-gyp\0.32.0\x64\nw.lib";"C:\Users\SF\.nw-gyp\0.32.0\x64\node.lib"
169 | /ignore:4199 /maxilksize:0x7ff00000 /fastfail %(AdditionalOptions)
170 | true
171 | true
172 | iojs.exe;node.exe;%(DelayLoadDLLs)
173 | true
174 | false
175 | false
176 | $(OutDir)$(ProjectName).node
177 | true
178 | true
179 | .node
180 | MachineX64
181 |
182 |
183 | C:\Users\SF\.nw-gyp\0.32.0\include\node;C:\Users\SF\.nw-gyp\0.32.0\src;C:\Users\SF\.nw-gyp\0.32.0\deps\uv\include;C:\Users\SF\.nw-gyp\0.32.0\deps\v8\include;%(AdditionalIncludeDirectories)
184 | NODE_GYP_MODULE_NAME=node_printer;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;BUILDING_NODE_EXTENSION;%(PreprocessorDefinitions);%(PreprocessorDefinitions)
185 |
186 |
187 |
188 |
189 | C:\Users\SF\.nw-gyp\0.32.0\include\node;C:\Users\SF\.nw-gyp\0.32.0\src;C:\Users\SF\.nw-gyp\0.32.0\deps\uv\include;C:\Users\SF\.nw-gyp\0.32.0\deps\v8\include;%(AdditionalIncludeDirectories)
190 | /bigobj /d2FastFail /Zc:sizedDealloc- /Zc:threadSafeInit- /MP %(AdditionalOptions)
191 | true
192 | false
193 | ProgramDatabase
194 | 4251;4275;4267;4351;4355;4800;4595;4251;%(DisableSpecificWarnings)
195 | false
196 | Speed
197 | true
198 | AnySuitable
199 | true
200 | true
201 | Full
202 | NotUsing
203 | NODE_GYP_MODULE_NAME=node_printer;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;BUILDING_NODE_EXTENSION;%(PreprocessorDefinitions)
204 | MultiThreaded
205 | false
206 | true
207 | true
208 | false
209 | Level3
210 | false
211 |
212 |
213 | kernel32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;user32.lib;uuid.lib;odbc32.lib;odbccp32.lib;delayimp.lib;credui.lib;dbghelp.lib;shlwapi.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;"C:\Users\SF\.nw-gyp\0.32.0\x64\nw.lib";"C:\Users\SF\.nw-gyp\0.32.0\x64\node.lib"
214 | /ignore:4199 /maxilksize:0x7ff00000 /fastfail %(AdditionalOptions)
215 | true
216 | true
217 | iojs.exe;node.exe;%(DelayLoadDLLs)
218 | true
219 | false
220 | false
221 | $(OutDir)$(ProjectName).node
222 | true
223 | true
224 | .node
225 | MachineX64
226 |
227 |
228 | C:\Users\SF\.nw-gyp\0.32.0\include\node;C:\Users\SF\.nw-gyp\0.32.0\src;C:\Users\SF\.nw-gyp\0.32.0\deps\uv\include;C:\Users\SF\.nw-gyp\0.32.0\deps\v8\include;%(AdditionalIncludeDirectories)
229 | NODE_GYP_MODULE_NAME=node_printer;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;BUILDING_NODE_EXTENSION;%(PreprocessorDefinitions);%(PreprocessorDefinitions)
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 | true
241 |
242 |
243 |
244 |
245 |
246 |
247 |
--------------------------------------------------------------------------------
/node_modules/printer/build/node_printer.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {739DB09A-CC57-A953-A6CF-F64FA08E4FA7}
6 |
7 |
8 | {8CDEE807-BC53-E450-C8B8-4DEBB66742D4}
9 |
10 |
11 | {739DB09A-CC57-A953-A6CF-F64FA08E4FA7}
12 |
13 |
14 | {8CDEE807-BC53-E450-C8B8-4DEBB66742D4}
15 |
16 |
17 | {7B735499-E5DD-1C2B-6C26-70023832A1CF}
18 |
19 |
20 | {E9F714C1-DA89-54E2-60CF-39FEB20BF756}
21 |
22 |
23 | {A3A55A83-A854-1856-B404-AF9F7473EA90}
24 |
25 |
26 | {F852EB63-437C-846A-220F-8D9ED6DAEC1D}
27 |
28 |
29 | {D51E5808-912B-5C70-4BB7-475D1DBFA067}
30 |
31 |
32 | {741E0E76-39B2-B1AB-9FA1-F1A20B16F295}
33 |
34 |
35 | {56DF7A98-063D-FB9D-485C-089023B4C16A}
36 |
37 |
38 | {3F3DA212-C923-AD55-6808-5CDB089DD269}
39 |
40 |
41 | {8CDEE807-BC53-E450-C8B8-4DEBB66742D4}
42 |
43 |
44 | {739DB09A-CC57-A953-A6CF-F64FA08E4FA7}
45 |
46 |
47 | {739DB09A-CC57-A953-A6CF-F64FA08E4FA7}
48 |
49 |
50 | {8CDEE807-BC53-E450-C8B8-4DEBB66742D4}
51 |
52 |
53 | {158E591E-B6EA-0C85-8F5A-18EAFA09B4CE}
54 |
55 |
56 |
57 |
58 | ..\src
59 |
60 |
61 | ..\src
62 |
63 |
64 | C:\Users\SF\AppData\Roaming\npm\node_modules\nw-gyp\src
65 |
66 |
67 | ..
68 |
69 |
70 | ..\src\_excluded_files
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/node_modules/printer/examples/cancelJob.js:
--------------------------------------------------------------------------------
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 | });
35 |
--------------------------------------------------------------------------------
/node_modules/printer/examples/example_zebra_printer.js:
--------------------------------------------------------------------------------
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");
16 |
--------------------------------------------------------------------------------
/node_modules/printer/examples/getDefaultPrinterName.js:
--------------------------------------------------------------------------------
1 | var printer = require("../lib");
2 |
3 | console.log('default printer name: ' + (printer.getDefaultPrinterName() || 'is not defined on your computer'));
4 |
5 |
--------------------------------------------------------------------------------
/node_modules/printer/examples/getPrinterDriverOptions.js:
--------------------------------------------------------------------------------
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 |
10 |
--------------------------------------------------------------------------------
/node_modules/printer/examples/getPrinters.js:
--------------------------------------------------------------------------------
1 | var printer = require("../lib"),
2 | util = require('util');
3 | console.log("installed printers:\n"+util.inspect(printer.getPrinters(), {colors:true, depth:10}));
4 |
--------------------------------------------------------------------------------
/node_modules/printer/examples/getSupportedFormats.js:
--------------------------------------------------------------------------------
1 | var printer = require("../lib"),
2 | util = require('util');
3 | console.log("supported formats are:\n"+util.inspect(printer.getSupportedPrintFormats(), {colors:true, depth:10}));
4 |
--------------------------------------------------------------------------------
/node_modules/printer/examples/getSupportedJobCommands.js:
--------------------------------------------------------------------------------
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}));
4 |
--------------------------------------------------------------------------------
/node_modules/printer/examples/printFile.js:
--------------------------------------------------------------------------------
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 | }
31 |
--------------------------------------------------------------------------------
/node_modules/printer/examples/printPDFFileInBuffer.js:
--------------------------------------------------------------------------------
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: [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 |
38 |
--------------------------------------------------------------------------------
/node_modules/printer/examples/printPDFInWindows.js:
--------------------------------------------------------------------------------
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: [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 |
53 |
--------------------------------------------------------------------------------
/node_modules/printer/examples/print_raw.js:
--------------------------------------------------------------------------------
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 | });
11 |
--------------------------------------------------------------------------------
/node_modules/printer/examples/test.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LittlehorseXie/nw-printer/ae517fa3a450ef8c591c09d28db3cf32f7396cdd/node_modules/printer/examples/test.pdf
--------------------------------------------------------------------------------
/node_modules/printer/lib/index.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./printer');
--------------------------------------------------------------------------------
/node_modules/printer/lib/printer.js:
--------------------------------------------------------------------------------
1 | var printer_helper = {},
2 | fs = require("fs"),
3 | child_process = require("child_process"),
4 | os = require("os"),
5 | path = require("path"),
6 | native_lib_path = path.join(__dirname, '../build/Release/node_printer.node'),
7 | printer_helper;
8 |
9 | if(fs.existsSync(native_lib_path)) {
10 | printer_helper = require(native_lib_path);
11 | } else {
12 | printer_helper = require('./node_printer_'+process.platform+'_'+process.arch+'.node');
13 | }
14 |
15 | /** Return all installed printers including active jobs
16 | */
17 | module.exports.getPrinters = getPrinters;
18 |
19 | /** send data to printer
20 | */
21 | module.exports.printDirect = printDirect;
22 |
23 | /// send file to printer
24 | module.exports.printFile = printFile;
25 |
26 | /** Get supported print format for printDirect
27 | */
28 | module.exports.getSupportedPrintFormats = printer_helper.getSupportedPrintFormats;
29 |
30 | /**
31 | * Get possible job command for setJob. It depends on os.
32 | * @return Array of string. e.g.: DELETE, PAUSE, RESUME
33 | */
34 | module.exports.getSupportedJobCommands = printer_helper.getSupportedJobCommands;
35 |
36 | /** get printer info object. It includes all active jobs
37 | */
38 | module.exports.getPrinter = getPrinter;
39 | module.exports.getSelectedPaperSize = getSelectedPaperSize;
40 | module.exports.getPrinterDriverOptions = getPrinterDriverOptions;
41 |
42 | /// Return default printer name
43 | module.exports.getDefaultPrinterName = getDefaultPrinterName;
44 |
45 | /** get printer job info object
46 | */
47 | module.exports.getJob = getJob;
48 | module.exports.setJob = setJob;
49 |
50 | /**
51 | * return user defined printer, according to https://www.cups.org/documentation.php/doc-2.0/api-cups.html#cupsGetDefault2 :
52 | * "Applications should use the cupsGetDests and cupsGetDest functions to get the user-defined default printer,
53 | * as this function does not support the lpoptions-defined default printer"
54 | */
55 | function getDefaultPrinterName() {
56 | var printerName = printer_helper.getDefaultPrinterName();
57 | if(printerName) {
58 | return printerName;
59 | }
60 |
61 | // seems correct posix behaviour
62 | var printers= getPrinters();
63 | for(i in printers) {
64 | var printer = printers[i];
65 | if(printer.isDefault === true) {
66 | return printer.name;
67 | }
68 | }
69 |
70 | // printer not found, return nothing(undefined)
71 | }
72 |
73 | /** Get printer info with jobs
74 | * @param printerName printer name to extract the info
75 | * @return printer object info:
76 | * TODO: to enum all possible attributes
77 | */
78 | function getPrinter(printerName)
79 | {
80 | if(!printerName) {
81 | printerName = getDefaultPrinterName();
82 | }
83 | var printer = printer_helper.getPrinter(printerName);
84 | correctPrinterinfo(printer);
85 | return printer;
86 | }
87 |
88 | /** Get printer driver options includes advanced options like supported paper size
89 | * @param printerName printer name to extract the info (default printer used if printer is not provided)
90 | * @return printer driver info:
91 | */
92 | function getPrinterDriverOptions(printerName)
93 | {
94 | if(!printerName) {
95 | printerName = getDefaultPrinterName();
96 | }
97 |
98 | return printer_helper.getPrinterDriverOptions(printerName);
99 | }
100 |
101 | /** Finds selected paper size pertaining to the specific printer out of all supported ones in driver_options
102 | * @param printerName printer name to extract the info (default printer used if printer is not provided)
103 | * @return selected paper size
104 | */
105 | function getSelectedPaperSize(printerName){
106 | var driver_options = getPrinterDriverOptions(printerName);
107 | var selectedSize = "";
108 | if (driver_options && driver_options.PageSize) {
109 | Object.keys(driver_options.PageSize).forEach(function(key){
110 | if (driver_options.PageSize[key])
111 | selectedSize = key;
112 | });
113 | }
114 | return selectedSize;
115 | }
116 |
117 | function getJob(printerName, jobId)
118 | {
119 | return printer_helper.getJob(printerName, jobId);
120 | }
121 |
122 | function setJob(printerName, jobId, command)
123 | {
124 | return printer_helper.setJob(printerName, jobId, command);
125 | }
126 |
127 | function getPrinters(){
128 | var printers = printer_helper.getPrinters();
129 | for(i in printers){
130 | correctPrinterinfo(printers[i]);
131 | }
132 | return printers;
133 | }
134 |
135 | function correctPrinterinfo(printer) {
136 | if(printer.status || !printer.options || !printer.options['printer-state']){
137 | return;
138 | }
139 |
140 | var status = printer.options['printer-state'];
141 | // Add posix status
142 | if(status == '3'){
143 | status = 'IDLE'
144 | }
145 | else if(status == '4'){
146 | status = 'PRINTING'
147 | }
148 | else if(status == '5'){
149 | status = 'STOPPED'
150 | }
151 |
152 | // correct date type
153 | var k;
154 | for(k in printer.options) {
155 | if(/time$/.test(k) && printer.options[k] && !(printer.options[k] instanceof Date)) {
156 | printer.options[k] = new Date(printer.options[k] * 1000);
157 | }
158 | }
159 |
160 | printer.status = status;
161 | }
162 |
163 | /*
164 | print raw data. This function is intend to be asynchronous
165 |
166 | parameters:
167 | parameters - Object, parameters objects with the following structure:
168 | data - String, mandatory, data to printer
169 | printer - String, optional, name of the printer, if missing, will try to print to default printer
170 | docname - String, optional, name of document showed in printer status
171 | type - String, optional, only for wind32, data type, one of the RAW, TEXT
172 | options - JS object with CUPS options, optional
173 | success - Function, optional, callback function
174 | error - Function, optional, callback function if exists any error
175 |
176 | or
177 |
178 | data - String, mandatory, data to printer
179 | printer - String, optional, name of the printer, if missing, will try to print to default printer
180 | docname - String, optional, name of document showed in printer status
181 | type - String, optional, data type, one of the RAW, TEXT
182 | options - JS object with CUPS options, optional
183 | success - Function, optional, callback function with first argument job_id
184 | error - Function, optional, callback function if exists any error
185 | */
186 | function printDirect(parameters){
187 | var data = parameters
188 | , printer
189 | , docname
190 | , type
191 | , options
192 | , success
193 | , error;
194 |
195 | if(arguments.length==1){
196 | //TODO: check parameters type
197 | //if (typeof parameters )
198 | data = parameters.data;
199 | printer = parameters.printer;
200 | docname = parameters.docname;
201 | type = parameters.type;
202 | options = parameters.options||{};
203 | success = parameters.success;
204 | error = parameters.error;
205 | }else{
206 | printer = arguments[1];
207 | type = arguments[2];
208 | docname = arguments[3];
209 | options = arguments[4];
210 | success = arguments[5];
211 | error = arguments[6];
212 | }
213 |
214 | if(!type){
215 | type = "RAW";
216 | }
217 |
218 | // Set default printer name
219 | if(!printer) {
220 | printer = getDefaultPrinterName();
221 | }
222 |
223 | type = type.toUpperCase();
224 |
225 | if(!docname){
226 | docname = "node print job";
227 | }
228 |
229 | if (!options){
230 | options = {};
231 | }
232 |
233 | //TODO: check parameters type
234 | if(printer_helper.printDirect){// call C++ binding
235 | try{
236 | var res = printer_helper.printDirect(data, printer, docname, type, options);
237 | if(res){
238 | success(res);
239 | }else{
240 | error(Error("Something wrong in printDirect"));
241 | }
242 | }catch (e){
243 | error(e);
244 | }
245 | }else{
246 | error("Not supported");
247 | }
248 | }
249 |
250 | /**
251 | parameters:
252 | parameters - Object, parameters objects with the following structure:
253 | filename - String, mandatory, data to printer
254 | docname - String, optional, name of document showed in printer status
255 | printer - String, optional, mane of the printer, if missed, will try to retrieve the default printer name
256 | success - Function, optional, callback function
257 | error - Function, optional, callback function if exists any error
258 | */
259 | function printFile(parameters){
260 | var filename,
261 | docname,
262 | printer,
263 | options,
264 | success,
265 | error;
266 |
267 | if((arguments.length !== 1) || (typeof(parameters) !== 'object')){
268 | throw new Error('must provide arguments object');
269 | }
270 |
271 | filename = parameters.filename;
272 | docname = parameters.docname;
273 | printer = parameters.printer;
274 | options = parameters.options || {};
275 | success = parameters.success;
276 | error = parameters.error;
277 |
278 | if(!success){
279 | success = function(){};
280 | }
281 |
282 | if(!error){
283 | error = function(err){
284 | throw err;
285 | };
286 | }
287 |
288 | if(!filename){
289 | var err = new Error('must provide at least a filename');
290 | return error(err);
291 | }
292 |
293 | // try to define default printer name
294 | if(!printer) {
295 | printer = getDefaultPrinterName();
296 | }
297 |
298 | if(!printer) {
299 | return error(new Error('Printer parameter of default printer is not defined'));
300 | }
301 |
302 | // set filename if docname is missing
303 | if(!docname){
304 | docname = filename;
305 | }
306 |
307 | //TODO: check parameters type
308 | if(printer_helper.printFile){// call C++ binding
309 | try{
310 | // TODO: proper success/error callbacks from the extension
311 | var res = printer_helper.printFile(filename, docname, printer, options);
312 |
313 | if(!isNaN(parseInt(res))) {
314 | success(res);
315 | } else {
316 | error(Error(res));
317 | }
318 | } catch (e) {
319 | error(e);
320 | }
321 | } else {
322 | error("Not supported");
323 | }
324 | }
325 |
--------------------------------------------------------------------------------
/node_modules/printer/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "_from": "printer@^0.2.2",
3 | "_id": "printer@0.2.2",
4 | "_inBundle": false,
5 | "_integrity": "sha1-gwuPXJe5f9m0ZNT04QXUMzd5IpY=",
6 | "_location": "/printer",
7 | "_phantomChildren": {},
8 | "_requested": {
9 | "type": "range",
10 | "registry": true,
11 | "raw": "printer@^0.2.2",
12 | "name": "printer",
13 | "escapedName": "printer",
14 | "rawSpec": "^0.2.2",
15 | "saveSpec": null,
16 | "fetchSpec": "^0.2.2"
17 | },
18 | "_requiredBy": [
19 | "#USER",
20 | "/"
21 | ],
22 | "_resolved": "https://registry.npmjs.org/printer/-/printer-0.2.2.tgz",
23 | "_shasum": "830b8f5c97b97fd9b464d4f4e105d43337792296",
24 | "_spec": "printer@^0.2.2",
25 | "_where": "C:\\Users\\Sf\\Desktop\\app",
26 | "author": {
27 | "name": "Ion Lupascu",
28 | "email": "ionlupascu@gmail.com",
29 | "url": "http://program-support.co.uk/"
30 | },
31 | "bugs": {
32 | "url": "https://github.com/tojocky/node-printer/issues"
33 | },
34 | "bundleDependencies": false,
35 | "contributors": [
36 | {
37 | "name": "Name Lastname",
38 | "email": "email@server.com"
39 | }
40 | ],
41 | "deprecated": false,
42 | "description": "Node.js printer bindings",
43 | "devDependencies": {
44 | "grunt": "^0.4.5",
45 | "grunt-contrib-copy": "^0.8.0",
46 | "grunt-contrib-jshint": "^0.11.0",
47 | "grunt-node-gyp": "git://github.com/tojocky/grunt-node-gyp.git",
48 | "grunt-nw-gyp": "git://github.com/tojocky/grunt-nw-gyp.git",
49 | "nodeunit": "*"
50 | },
51 | "engines": {
52 | "node": ">= 0.8.0"
53 | },
54 | "gypfile": true,
55 | "homepage": "http://github.com/tojocky/node-printer",
56 | "licenses": [
57 | {
58 | "type": "BSD"
59 | }
60 | ],
61 | "main": "./lib/printer",
62 | "name": "printer",
63 | "repository": {
64 | "type": "git",
65 | "url": "git://github.com/tojocky/node-printer.git"
66 | },
67 | "scripts": {
68 | "install": "node-gyp rebuild"
69 | },
70 | "version": "0.2.2"
71 | }
72 |
--------------------------------------------------------------------------------
/node_modules/printer/printer.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./lib/printer');
--------------------------------------------------------------------------------
/node_modules/printer/src/macros.hh:
--------------------------------------------------------------------------------
1 | #ifndef NODE_PRINTER_SRC_MACROS_H
2 | #define NODE_PRINTER_SRC_MACROS_H
3 |
4 | #include
5 |
6 | // NODE_MODULE_VERSION was incremented for v0.11
7 |
8 |
9 | #if NODE_VERSION_AT_LEAST(0, 11, 9)
10 | # define MY_NODE_MODULE_ISOLATE_DECL v8::Isolate* isolate = v8::Isolate::GetCurrent();
11 | # define MY_NODE_MODULE_ISOLATE isolate
12 | # define MY_NODE_MODULE_ISOLATE_PRE isolate,
13 | # define MY_NODE_MODULE_ISOLATE_POST , isolate
14 | # define MY_NODE_MODULE_HANDLESCOPE MY_NODE_MODULE_ISOLATE_DECL v8::HandleScope scope(MY_NODE_MODULE_ISOLATE)
15 | # define MY_NODE_MODULE_CALLBACK(name) void name(const v8::FunctionCallbackInfo& iArgs)
16 | # define V8_VALUE_NEW(type, value) v8::type::New(MY_NODE_MODULE_ISOLATE_PRE value)
17 | # define V8_VALUE_NEW_DEFAULT(type) v8::type::New(MY_NODE_MODULE_ISOLATE)
18 | # define V8_STRING_NEW_UTF8(value) v8::String::NewFromUtf8(MY_NODE_MODULE_ISOLATE_PRE value)
19 | # define V8_STRING_NEW_2BYTES(value) v8::String::NewFromTwoByte(MY_NODE_MODULE_ISOLATE_PRE value)
20 |
21 | # define RETURN_EXCEPTION(msg) isolate->ThrowException(v8::Exception::TypeError(msg)); \
22 | return
23 |
24 | # define RETURN_EXCEPTION_STR(msg) RETURN_EXCEPTION(V8_STRING_NEW_UTF8(msg))
25 | # define MY_NODE_MODULE_RETURN_VALUE(value) iArgs.GetReturnValue().Set(value); \
26 | return
27 | # define MY_NODE_MODULE_RETURN_UNDEFINED() return
28 | #else
29 | # define MY_NODE_MODULE_ISOLATE_DECL
30 | # define MY_NODE_MODULE_ISOLATE
31 | # define MY_NODE_MODULE_ISOLATE_PRE
32 | # define MY_NODE_MODULE_ISOLATE_POST
33 | # define MY_NODE_MODULE_HANDLESCOPE v8::HandleScope scope;
34 | # define MY_NODE_MODULE_CALLBACK(name) v8::Handle name(const v8::Arguments& iArgs)
35 | # define V8_VALUE_NEW(type, value) v8::type::New(value)
36 | # define V8_VALUE_NEW_DEFAULT(type) v8::type::New()
37 | # define V8_STRING_NEW_UTF8(value) v8::String::New(MY_NODE_MODULE_ISOLATE_PRE value)
38 | # define V8_STRING_NEW_2BYTES(value) v8::String::New(MY_NODE_MODULE_ISOLATE_PRE value)
39 |
40 | # define RETURN_EXCEPTION(msg) return v8::ThrowException(v8::Exception::TypeError(msg))
41 |
42 | # define RETURN_EXCEPTION_STR(msg) RETURN_EXCEPTION(V8_STRING_NEW_UTF8(msg))
43 | # define MY_NODE_MODULE_RETURN_VALUE(value) return scope.Close(value)
44 | # define MY_NODE_MODULE_RETURN_UNDEFINED() return scope.Close(v8::Undefined())
45 | #endif
46 |
47 | #if NODE_VERSION_AT_LEAST(0, 11, 10) // for node-webkit v.0.9.2 which uses node v0.11.9
48 | # define V8_VALUE_NEW_V_0_11_10(type, value) v8::type::New(MY_NODE_MODULE_ISOLATE_PRE value)
49 | # define V8_VALUE_NEW_DEFAULT_V_0_11_10(type) v8::type::New(MY_NODE_MODULE_ISOLATE)
50 | #else
51 | # define V8_VALUE_NEW_V_0_11_10(type, value) v8::type::New(value)
52 | # define V8_VALUE_NEW_DEFAULT_V_0_11_10(type) v8::type::New()
53 | #endif
54 |
55 |
56 | #define V8_STR_CONC(left, right) \
57 | v8::String::Concat(V8_STRING_NEW_UTF8(left), V8_STRING_NEW_UTF8(right))
58 |
59 | #define REQUIRE_ARGUMENTS(args, n) \
60 | if (args.Length() < (n)) { \
61 | RETURN_EXCEPTION_STR("Expected " #n " arguments"); \
62 | }
63 |
64 |
65 | #define REQUIRE_ARGUMENT_EXTERNAL(i, var) \
66 | if (args.Length() <= (i) || !args[i]->IsExternal()) { \
67 | RETURN_EXCEPTION_STR("Argument " #i " invalid"); \
68 | } \
69 | v8::Local var = v8::Local::Cast(args[i]);
70 |
71 | #define REQUIRE_ARGUMENT_OBJECT(args, i, var) \
72 | if (args.Length() <= (i) || !args[i]->IsObject()) { \
73 | RETURN_EXCEPTION_STR("Argument " #i " is not an object"); \
74 | } \
75 | v8::Local var = v8::Local::Cast(args[i]);
76 |
77 |
78 | #define REQUIRE_ARGUMENT_FUNCTION(i, var) \
79 | if (args.Length() <= (i) || !args[i]->IsFunction()) { \
80 | RETURN_EXCEPTION_STR("Argument " #i " must be a function"); \
81 | } \
82 | v8::Local var = v8::Local::Cast(args[i]);
83 |
84 |
85 | #define ARG_CHECK_STRING(args, i) \
86 | if (args.Length() <= (i) || !args[i]->IsString()) { \
87 | RETURN_EXCEPTION_STR("Argument " #i " must be a string"); \
88 | } \
89 |
90 | #define REQUIRE_ARGUMENT_STRING(args, i, var) \
91 | ARG_CHECK_STRING(args, i); \
92 | v8::String::Utf8Value var(args[i]->ToString());
93 |
94 | #define REQUIRE_ARGUMENT_STRINGW(args, i, var) \
95 | ARG_CHECK_STRING(args, i); \
96 | v8::String::Value var(args[i]->ToString());
97 |
98 |
99 | #define OPTIONAL_ARGUMENT_FUNCTION(i, var) \
100 | v8::Local var; \
101 | if (args.Length() > i && !args[i]->IsUndefined()) { \
102 | if (!args[i]->IsFunction()) { \
103 | RETURN_EXCEPTION_STR("Argument " #i " must be a function"); \
104 | } \
105 | var = v8::Local::Cast(args[i]); \
106 | }
107 |
108 |
109 | #define REQUIRE_ARGUMENT_INTEGER(args, i, var) \
110 | int var; \
111 | if (args[i]->IsInt32()) { \
112 | var = args[i]->Int32Value(); \
113 | } \
114 | else { \
115 | RETURN_EXCEPTION_STR("Argument " #i " must be an integer"); \
116 | }
117 |
118 | #define OPTIONAL_ARGUMENT_INTEGER(args, i, var, default) \
119 | int var; \
120 | if (args.Length() <= (i)) { \
121 | var = (default); \
122 | } \
123 | else if (args[i]->IsInt32()) { \
124 | var = args[i]->Int32Value(); \
125 | } \
126 | else { \
127 | RETURN_EXCEPTION_STR("Argument " #i " must be an integer"); \
128 | }
129 | #define EMIT_EVENT(obj, argc, argv) \
130 | TRY_CATCH_CALL((obj), \
131 | Local::Cast((obj)->Get(String::NewSymbol("emit"))), \
132 | argc, argv \
133 | );
134 |
135 | #define TRY_CATCH_CALL(context, callback, argc, argv) \
136 | { TryCatch try_catch; \
137 | (callback)->Call((context), (argc), (argv)); \
138 | if (try_catch.HasCaught()) { \
139 | FatalException(try_catch); \
140 | } \
141 | }
142 |
143 | #endif
144 |
--------------------------------------------------------------------------------
/node_modules/printer/src/node_printer.cc:
--------------------------------------------------------------------------------
1 | #include "node_printer.hpp"
2 |
3 | #include
4 |
5 | void initNode(v8::Handle exports) {
6 | // only for node
7 | NODE_SET_METHOD(exports, "getPrinters", getPrinters);
8 | NODE_SET_METHOD(exports, "getDefaultPrinterName", getDefaultPrinterName);
9 | NODE_SET_METHOD(exports, "getPrinter", getPrinter);
10 | NODE_SET_METHOD(exports, "getPrinterDriverOptions", getPrinterDriverOptions);
11 | NODE_SET_METHOD(exports, "getJob", getJob);
12 | NODE_SET_METHOD(exports, "setJob", setJob);
13 | NODE_SET_METHOD(exports, "printDirect", PrintDirect);
14 | NODE_SET_METHOD(exports, "printFile", PrintFile);
15 | NODE_SET_METHOD(exports, "getSupportedPrintFormats", getSupportedPrintFormats);
16 | NODE_SET_METHOD(exports, "getSupportedJobCommands", getSupportedJobCommands);
17 | }
18 |
19 | NODE_MODULE(node_printer, initNode);
20 |
21 | // Helpers
22 |
23 | bool getStringOrBufferFromV8Value(v8::Handle iV8Value, std::string &oData)
24 | {
25 | if(iV8Value->IsString())
26 | {
27 | v8::String::Utf8Value data_str_v8(iV8Value->ToString());
28 | oData.assign(*data_str_v8, data_str_v8.length());
29 | return true;
30 | }
31 | if(iV8Value->IsObject() && node::Buffer::HasInstance(iV8Value))
32 | {
33 | oData.assign(node::Buffer::Data(iV8Value), node::Buffer::Length(iV8Value));
34 | return true;
35 | }
36 | return false;
37 | }
38 |
--------------------------------------------------------------------------------
/node_modules/printer/src/node_printer.hpp:
--------------------------------------------------------------------------------
1 | #ifndef NODE_PRINTER_HPP
2 | #define NODE_PRINTER_HPP
3 |
4 | #include "macros.hh"
5 |
6 | #include
7 | #include
8 |
9 | #include
10 |
11 | /**
12 | * Send data to printer
13 | *
14 | * @param data String/NativeBuffer, mandatory, raw data bytes
15 | * @param printername String, mandatory, specifying printer name
16 | * @param docname String, mandatory, specifying document name
17 | * @param type String, mandatory, specifying data type. E.G.: RAW, TEXT, ...
18 | *
19 | * @returns true for success, false for failure.
20 | */
21 | MY_NODE_MODULE_CALLBACK(PrintDirect);
22 |
23 | /**
24 | * Send file to printer
25 | *
26 | * @param filename String, mandatory, specifying filename to print
27 | * @param docname String, mandatory, specifying document name
28 | * @param printer String, mandatory, specifying printer name
29 | *
30 | * @returns jobId for success, or error message for failure.
31 | */
32 | MY_NODE_MODULE_CALLBACK(PrintFile);
33 |
34 | /** Retrieve all printers and jobs
35 | * posix: minimum version: CUPS 1.1.21/OS X 10.4
36 | */
37 | MY_NODE_MODULE_CALLBACK(getPrinters);
38 |
39 | /**
40 | * Return default printer name, if null then default printer is not set
41 | */
42 | MY_NODE_MODULE_CALLBACK(getDefaultPrinterName);
43 |
44 | /** Retrieve printer info and jobs
45 | * @param printer name String
46 | */
47 | MY_NODE_MODULE_CALLBACK(getPrinter);
48 |
49 | /** Retrieve printer driver info
50 | * @param printer name String
51 | */
52 | MY_NODE_MODULE_CALLBACK(getPrinterDriverOptions);
53 |
54 | /** Retrieve job info
55 | * @param printer name String
56 | * @param job id Number
57 | */
58 | MY_NODE_MODULE_CALLBACK(getJob);
59 |
60 | //TODO
61 | /** Set job command.
62 | * arguments:
63 | * @param printer name String
64 | * @param job id Number
65 | * @param job command String
66 | * Possible commands:
67 | * "CANCEL"
68 | * "PAUSE"
69 | * "RESTART"
70 | * "RESUME"
71 | * "DELETE"
72 | * "SENT-TO-PRINTER"
73 | * "LAST-PAGE-EJECTED"
74 | * "RETAIN"
75 | * "RELEASE"
76 | */
77 | MY_NODE_MODULE_CALLBACK(setJob);
78 |
79 | /** Get supported print formats for printDirect. It depends on platform
80 | */
81 | MY_NODE_MODULE_CALLBACK(getSupportedPrintFormats);
82 |
83 | /** Get supported job commands for setJob method
84 | */
85 | MY_NODE_MODULE_CALLBACK(getSupportedJobCommands);
86 |
87 | //TODO:
88 | // optional ability to get printer spool
89 |
90 |
91 | // util class
92 |
93 | /** Memory value class management to avoid memory leak
94 | * TODO: move to std::unique_ptr on switching to C++11
95 | */
96 | template
97 | class MemValueBase
98 | {
99 | public:
100 | MemValueBase(): _value(NULL) {}
101 |
102 | /** Destructor. The allocated memory will be deallocated
103 | */
104 | ~MemValueBase() {}
105 |
106 | Type * get() {return _value; }
107 | Type * operator ->() { return &_value; }
108 | operator bool() const { return (_value != NULL); }
109 | protected:
110 | Type *_value;
111 |
112 | virtual void free() {};
113 | };
114 |
115 | /**
116 | * try to extract String or buffer from v8 value
117 | * @param iV8Value - source v8 value
118 | * @param oData - destination data
119 | * @return TRUE if value is String or Buffer, FALSE otherwise
120 | */
121 | bool getStringOrBufferFromV8Value(v8::Handle iV8Value, std::string &oData);
122 |
123 | #endif
124 |
--------------------------------------------------------------------------------
/node_modules/printer/src/node_printer_posix.cc:
--------------------------------------------------------------------------------
1 | #include "node_printer.hpp"
2 |
3 | #include
4 | #include