I'm trying to use node printer from an Electron application, but as soon I add the lines to use the printer, the app crashes.
The console outputs this:
[1] 9860 segmentation fault (core dumped) node_modules/electron-prebuilt/dist/electron.
This is the app I'm running:
var app = require('app');
var BrowserWindow = require('browser-window');
var printer = require('printer');
require('crash-reporter').start();
app.on('ready', function() {
var mainWindow = new BrowserWindow({width: 800, height: 600});
mainWindow.loadUrl('file://' + __dirname + '/app/index.html');
mainWindow.openDevTools();
printer.printDirect({data:"print from Node.JS buffer" // or simple String: "some text"
, printer:'HP-Deskjet-F4400-series' // printer name, if missing then will print to default printer
, type: 'TEXT' // 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);}
});
});
Am I missing something?
I tried the node printer on its own, and I successfully printed some gibberish text.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…