Sto tentando di utilizzare node printer da un'applicazione di elettroni, ma non appena aggiungo le linee per utilizzare la stampante, l'app si arresta in modo anomalo.Stampa da applicazione elettronica
Le uscite Console: [1] 9860 segmentation fault (core dumped) node_modules/electron-prebuilt/dist/electron.
Questa è l'applicazione sto correndo. Ho solo aggiunto le righe di stampa al semplice esempio di app fornito sulla documentazione elettronica:
var app = require('app'); // Module to control application life.
var BrowserWindow = require('browser-window'); // Module to create native browser window.
var printer = require('printer');
// Report crashes to our server.
require('crash-reporter').start();
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is GCed.
var mainWindow = null;
// Quit when all windows are closed.
app.on('window-all-closed', function() {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform != 'darwin') {
app.quit();
}
});
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', function() {
// Create the browser window.
mainWindow = new BrowserWindow({width: 800, height: 600});
// and load the index.html of the app.
mainWindow.loadUrl('file://' + __dirname + '/app/index.html');
// Open the devtools.
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);}
});
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
});
Mi manca qualcosa? Ho provato la stampante del nodo da sola e ho stampato con successo un testo senza senso.
lo ha fatto senza successo. Questo è ciò che succede ora: 'npm ERR! Failed at [email protected] installa script 'node-gyp rebuild'. npm ERR! Questo è probabilmente un problema con il pacchetto della stampante, ERR npm! non con npm stesso. npm ERR! Dì all'autore che questo non funziona sul tuo sistema: npm ERR! node-gyp rebuild npm ERR! È possibile ottenere le loro informazioni tramite: npm ERR! npm owner ls printer npm ERR! Probabilmente c'è un ulteriore output di registrazione sopra. – leamasuero
@leamasuero Vedi i documenti, c'è anche un altro modo di usare il nodo-gyp. forse questo aiuta –