Skip to content

Commit

Permalink
New Version
Browse files Browse the repository at this point in the history
  • Loading branch information
marcopiraccini committed Feb 15, 2016
1 parent 16227ff commit fd60dbe
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 44 deletions.
26 changes: 13 additions & 13 deletions examples/cancelJob.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
var printer = require("../lib"),
var printer = require(".."),
util = require('util'),
printerName = 'Foxit Reader PDF Printer',
printerFormat = 'TEXT';

printer.printDirect({
data:"print from Node.JS buffer", // or simple String: "some text"
printer:printerName, // printer name
type: printerFormat, // type: RAW, TEXT, PDF, JPEG, .. depends on platform
printer:printerName, // printer name
type: printerFormat, // type: RAW, TEXT, PDF, JPEG, .. depends on platform
options: // supported page sizes may be retrieved using getPrinterDriverOptions, supports CUPS printing options
{
media: 'Letter',
'fit-to-page': true
},
success:function(jobID){
console.log("sent to printer with ID: "+jobID);
success:function(jobID){
console.log("sent to printer with ID: "+jobID);
var jobInfo = printer.getJob(printerName, jobID);
console.log("current job info:"+util.inspect(jobInfo, {depth: 10, colors:true}));
if(jobInfo.status.indexOf('PRINTED') !== -1)
Expand All @@ -23,12 +23,12 @@ printer.printDirect({
}
console.log('cancelling...');
var is_ok = printer.setJob(printerName, jobID, 'CANCEL');
console.log("cancelled: "+is_ok);
try{
console.log("current job info:"+util.inspect(printer.getJob(printerName, jobID), {depth: 10, colors:true}));
}catch(err){
console.log('job deleted. err:'+err);
}
},
error:function(err){console.log(err);}
console.log("cancelled: "+is_ok);
try{
console.log("current job info:"+util.inspect(printer.getJob(printerName, jobID), {depth: 10, colors:true}));
}catch(err){
console.log('job deleted. err:'+err);
}
},
error:function(err){console.log(err);}
});
20 changes: 10 additions & 10 deletions examples/example_zebra_printer.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
var printer = require("../lib")
, template = "N\nS4\nD15\nq400\nR\nB20,10,0,1,2,30,173,B,\"barcode\"\nP0\n";
var printer = require("..")
, template = "N\nS4\nD15\nq400\nR\nB20,10,0,1,2,30,173,B,\"barcode\"\nP0\n";

function printZebra(barcode_text, printer_name){
printer.printDirect({data:template.replace(/barcode/, barcode_text)
, printer:printer_name
, type: "RAW"
, success:function(){
console.log("printed: "+barcode_text);
}
, error:function(err){console.log(err);}
});
printer.printDirect({data:template.replace(/barcode/, barcode_text)
, printer:printer_name
, type: "RAW"
, success:function(){
console.log("printed: "+barcode_text);
}
, error:function(err){console.log(err);}
});
}

printZebra("123", "ZEBRA");
3 changes: 1 addition & 2 deletions examples/getDefaultPrinterName.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var printer = require("../lib");
var printer = require("..");

console.log('default printer name: ' + (printer.getDefaultPrinterName() || 'is not defined on your computer'));

3 changes: 1 addition & 2 deletions examples/getPrinterDriverOptions.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
var printer = require("../lib"),
var printer = require(".."),
util = require('util'),
printers = printer.getPrinters();

printers.forEach(function(iPrinter, i){
console.log('' + i + 'ppd for printer "' + iPrinter.name + '":' + util.inspect(printer.getPrinterDriverOptions(iPrinter.name), {colors:true, depth:10} ));
console.log('\tselected page size:'+ printer.getSelectedPaperSize(iPrinter.name) + '\n');
});

2 changes: 1 addition & 1 deletion examples/getSupportedFormats.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
var printer = require("../lib"),
var printer = require(".."),
util = require('util');
console.log("supported formats are:\n"+util.inspect(printer.getSupportedPrintFormats(), {colors:true, depth:10}));
2 changes: 1 addition & 1 deletion examples/getSupportedJobCommands.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
var printer = require("../lib"), //=require('pritner')
var printer = require(".."), //=require('pritner')
util = require('util');
console.log("supported job commands:\n"+util.inspect(printer.getSupportedJobCommands(), {colors:true, depth:10}));
2 changes: 1 addition & 1 deletion examples/printFile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// use: node printFile.js [filePath printerName]
var printer = require("../lib"),
var printer = require(".."),
filename = process.argv[2] || __filename;

console.log('platform:', process.platform);
Expand Down
3 changes: 1 addition & 2 deletions examples/printPDFFileInBuffer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Windows does not support PDF formats, but you can use imagemagick-native to achieve conversion from PDF to EMF.

var printer = require("../lib"),
var printer = require(".."),
fs = require('fs'),
path = require('path'),
filename = process.argv[2],
Expand Down Expand Up @@ -34,4 +34,3 @@ fs.readFile(filename, function(err, data){
}
})
});

4 changes: 1 addition & 3 deletions examples/printPDFInWindows.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Windows does not support PDF formats, but you can use imagemagick-native to achieve conversion from PDF to EMF.

var printer = require("../lib"),
var printer = require(".."),
imagemagick, // will be loaded later with proper error.
fs = require('fs'),
filename = process.argv[2],
Expand Down Expand Up @@ -48,5 +48,3 @@ imagemagick.convert({
}
})
})


14 changes: 7 additions & 7 deletions examples/print_raw.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var printer = require("../lib");
var printer = require("..");

printer.printDirect({data:"print from Node.JS buffer" // or simple String: "some text"
//, printer:'Foxit Reader PDF Printer' // printer name, if missing then will print to default printer
, type: 'RAW' // type: RAW, TEXT, PDF, JPEG, .. depends on platform
, success:function(jobID){
console.log("sent to printer with ID: "+jobID);
}
, error:function(err){console.log(err);}
//, printer:'Foxit Reader PDF Printer' // printer name, if missing then will print to default printer
, type: 'RAW' // type: RAW, TEXT, PDF, JPEG, .. depends on platform
, success:function(jobID){
console.log("sent to printer with ID: "+jobID);
}
, error:function(err){console.log(err);}
});
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "electron-printer",
"description": "Node.js printer bindings - electron builds",
"version": "0.0.4",
"version": "0.0.5",
"homepage": "https://github.com/marcopiraccini/electron-printer",
"author": {
"name": "Marco Piraccini",
Expand Down Expand Up @@ -30,7 +30,7 @@
"module_name": "node_printer",
"module_path": "./build/{configuration}/electron-v0.36-{platform}-{arch}/",
"package_name": "electron-v0.36-{platform}-{arch}.tar.gz",
"host": "https://github.com/marcopiraccini/electron-printer/releases/download/0.0.4"
"host": "https://github.com/marcopiraccini/electron-printer/releases/download/0.0.5"
},
"dependencies": {
"nan": "^2.1.0",
Expand Down

0 comments on commit fd60dbe

Please sign in to comment.