Commit 08e2c981 authored by Shawn Liu's avatar Shawn Liu
Browse files

Add printserverWin.js and printer module.

parent bfe68a04
env:
matrix:
- export NODE_VERSION="5.9"
- export NODE_VERSION="4.4"
- export NODE_VERSION="0.10"
matrix:
fast_finish: true
allow_failures:
- env: NODE_VERSION="0.10"
- env: NODE_VERSION="iojs"
before_install:
- git clone https://github.com/creationix/nvm.git ./.nvm
- source ./.nvm/nvm.sh
- nvm install $NODE_VERSION
- echo $NODE_VERSION
- nvm use $NODE_VERSION
- if [ $TRAVIS_OS_NAME == "linux" ]; then
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test;
sudo apt-get -qq update;
sudo apt-get -qq install g++-4.8;
export CXX='g++-4.8';
sudo apt-get install -qq debhelper autotools-dev cups-ppdc libcups2-dev cups imagemagick ghostscript;
fi
- "export JOBS=4"
- BUILD_ONLY=true npm install
before_script:
- git config --global user.name "Ion Lupascu"
- git config --global user.email ionlupascu@gmail.com
git:
depth: 1
branches:
only:
- master
os:
- linux
- osx
script: npm test
2016.09.10, version 0.2.2
* correct memory leak (thanks to @kjlaw89)
2015.10.22, version 0.2.1
* corrected printDirect with buffer data for node v4.X (#95)
* corrected segmentation fault from get default printer for node v0.10.X
2015.09, version 0.2.0
* added possibility to compile with node v4.X
* various bug/core dumps fix
2015.04, version 0.1.2
* posix: new method getPrinterDriverOptions(printerName) to retrieve PPD options
* posix: new method getSelectedPaperSize(printerName) to retrieve the current paper size name
* posix: new parameter `options` added to `printDirect` to set printer options (ex. `fit-to-page`, `media`, etc)
* posix: new function printFile() to print a file
2015.03.03, version 0.1.1
* possibility to build for node-webkit with grunt
2015.02.26, version 0.1.0
* possibility to load native module for platform/arch: node_module_{platform}_{arch}.node
2015.02.24, Version 0.0.5
* added getDefaultPrinterName() method by returning the default printer name
* make printer argument optional in getPrinter() and printDirect. If is missing, will try to print to default printer
* resolve charest of getPrinter() #38
* posix/win32: added more explicit errors
* posix: do not throw error if job status code is not supported
2015.01.30, Version 0.0.4
* win: added RPC installed printers in getPrinters #40
* posix: on some devices not all formats are supported, issue #23
* posix: added link settings on build #28
* corrected README.md
* corrected examples
module.exports = function(grunt) {
grunt.initConfig({
gyp: {
ia32: {
command: 'rebuild',
options: {
arch: 'ia32'
}
},
x64: {
command: 'rebuild',
options: {
arch: 'x64'
}
}
},
"nw-gyp": {
ia32: {
command: 'rebuild',
options: {
arch: 'ia32'
}
},
x64: {
command: 'rebuild',
options: {
arch: 'x64'
}
}
},
copy: {
ia32: {
files: [{src: 'build/Release/node_printer.node', dest: 'lib/node_printer_' + process.platform + '_ia32.node'}]
},
x64: {
files: [{src: 'build/Release/node_printer.node', dest: 'lib/node_printer_' + process.platform + '_x64.node'}]
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-node-gyp');
grunt.loadNpmTasks('grunt-nw-gyp');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.registerTask('build-nw-ia32', [
'nw-gyp:ia32',
'copy:ia32'
]);
grunt.registerTask('build-ia32', [
'gyp:ia32',
'copy:ia32'
]);
grunt.registerTask('build-x64', [
'gyp:x64',
'copy:x64'
]);
grunt.registerTask('build-nw-x64', [
'nw-gyp:x64',
'copy:x64'
]);
grunt.registerTask('build', [
'build-ia32',
'build-x64'
]);
grunt.registerTask('build-nw', [
'build-nw-ia32',
'build-nw-x64'
]);
}
node-printer
============
Native bind printers on POSIX and Windows OS from Node.js, iojs and node-webkit.
<table>
<thead>
<tr>
<th>Linux</th>
<th>Windows</th>
<th>Dependencies</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">
<a href="https://travis-ci.org/tojocky/node-printer"><img src="https://travis-ci.org/tojocky/node-printer.svg?branch=master"></a>
</td>
<td align="center">
<a href="https://ci.appveyor.com/project/tojocky/node-printer"><img src="https://ci.appveyor.com/api/projects/status/9y800f36wla35ee7?svg=true"></a>
</td>
<td align="center">
<a href="https://david-dm.org/tojocky/node-printer"><img src="https://david-dm.org/tojocky/node-printer.svg"></a>
</td>
</tr>
</tbody>
</table>
If you have a problem, ask question to [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](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)
### Reason:
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.
### Features:
* no dependecies;
* native method wrappers from Windows and POSIX (which uses [CUPS 1.4/MAC OS X 10.6](http://cups.org/)) APIs;
* compatible with node v0.8.x, 0.9.x and v0.11.x (with 0.11.9 and 0.11.13);
* compatible with node-webkit v0.8.x and 0.9.2;
* `getPrinters()` to enumerate all installed printers with current jobs and statuses;
* `getPrinter(printerName)` to get a specific/default printer info with current jobs and statuses;
* `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
* `getSelectedPaperSize(printerName)` ([POSIX](http://en.wikipedia.org/wiki/POSIX) only) to get a specific/default printer default paper size from its driver options
* `getDefaultPrinterName()` return the default printer name;
* `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;
* `printFile(options)` ([POSIX](http://en.wikipedia.org/wiki/POSIX) only) to print a file;
* `getSupportedPrintFormats()` to get all possible print formats for printDirect method which depends on OS. `RAW` and `TEXT` are supported from all OS-es;
* `getJob(printerName, jobId)` to get a specific job info including job status;
* `setJob(printerName, jobId, command)` to send a command to a job (e.g. `'CANCEL'` to cancel the job);
* `getSupportedJobCommands()` to get supported job commands for setJob() depends on OS. `'CANCEL'` command is supported from all OS-es.
### How to install:
Make sure you have Python 2.x installed on your system. Windows users will also require Visual Studio (2013 Express is a good fit)
from [npmjs.org](https://www.npmjs.org/package/printer)
npm install -g node-gyp
npm install printer --msvs_version=2013
or [direct from git](https://www.npmjs.org/doc/cli/npm-install.html):
npm install git+https://github.com/tojocky/node-printer.git
if you want to to run in [nwjs](http://nwjs.io/) then rebuild the module with [nw-gyp](https://github.com/nwjs/nw-gyp):
```
npm install -g nw-gyp
cd node_modules/printer
nw-gyp rebuild
```
For specific distribution `--dist-url` node-gyp parameter should be used. Example for electron:
```
node-gyp rebuild --target=0.37.4 --arch=x64 --dist-url=https://atom.io/download/atom-shell
```
Ubuntu User :
You need to install libcups2-dev package
`sudo apt-get install libcups2-dev`
### How to use:
See [examples](https://github.com/tojocky/node-printer/tree/master/examples)
### Author(s):
* Ion Lupascu, ionlupascu@gmail.com
### Contibutors:
Feel free to download, test and propose new futures
### License:
[The MIT License (MIT)](http://opensource.org/licenses/MIT)
# appveyor file
# http://www.appveyor.com/docs/appveyor-yml
# Try out "interactive-mode"
os: Windows Server 2012 R2
# build version format
version: "{build}"
# Set a known clone folder
clone_folder: c:\projects\node-printer
# fix lineendings in Windows
init:
- git config --global core.autocrlf input
- git config --global user.name "Ion Lupascu"
- git config --global user.email ionlupascu@gmail.com
# what combinations to test
environment:
matrix:
# Node.js
- nodejs_version: "0.10"
- nodejs_version: "0.12"
- nodejs_version: "4.4"
- nodejs_version: "5.9"
matrix:
fast_finish: true
allow_failures:
- nodejs_version: "0.10"
# Get the latest stable version of Node 0.STABLE.latest
install:
- ps: Install-Product node $env:nodejs_version
- cmd: SET PATH=C:\Program Files (x86)\MSBuild\12.0\bin\;%PATH%
- cmd: SET PATH=c:\python27;%PATH%
- cmd: SET JOBS=4
- cmd: SET BUILD_ONLY=true
- cmd: npm install -g node-gyp
- npm install --msvs_version=2013
test_script:
- node --version
- npm --version
# - cmd: npm test
build: off
branches:
only:
- master
{
'targets': [
{
'target_name': 'node_printer',
'sources': [
# is like "ls -1 src/*.cc", but gyp does not support direct patterns on
# sources
'<!@(["python", "tools/getSourceFiles.py", "src", "cc"])'
],
'conditions': [
# common exclusions
['OS!="linux"', {'sources/': [['exclude', '_linux\\.cc$']]}],
['OS!="mac"', {'sources/': [['exclude', '_mac\\.cc|mm?$']]}],
['OS!="win"', {
'sources/': [['exclude', '_win\\.cc$']]}, {
# else if OS==win, exclude also posix files
'sources/': [['exclude', '_posix\\.cc$']]
}],
# specific settings
['OS!="win"', {
'cflags':[
'<!(cups-config --cflags)'
],
'ldflags':[
'<!(cups-config --libs)'
#'-lcups -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lz -lpthread -lm -lcrypt -lz'
],
'libraries':[
'<!(cups-config --libs)'
#'-lcups -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lz -lpthread -lm -lcrypt -lz'
],
'link_settings': {
'libraries': [
'<!(cups-config --libs)'
]
}
}]
]
}
]
}
This source diff could not be displayed because it is too large. You can view the blob instead.
B^C:\MIT\FABLAB\PRINTSERVER\NODE_MODULES\PRINTER\SRC\NODE_PRINTER.CC
B^C:\PROGRAM FILES\NODEJS\NODE_MODULES\NPM\NODE_MODULES\NODE-GYP\SRC\WIN_DELAY_LOAD_HOOK.CC
B^C:\MIT\FABLAB\PRINTSERVER\NODE_MODULES\PRINTER\SRC\NODE_PRINTER.CC|C:\MIT\FABLAB\PRINTSERVER\NODE_MODULES\PRINTER\SRC\NODE_PRINTER_WIN.CC|C:\PROGRAM FILES\NODEJS\NODE_MODULES\NPM\NODE_MODULES\NODE-GYP\SRC\WIN_DELAY_LOAD_HOOK.CC
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment