Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const fs = nw.require('fs');
- let filename = "PA_Parrot.jpg";
- let fileToPrintPath = global.__dirname + '/tmp/' + filename;
- let stream = fs.createReadStream(filename).pipe(fs.createWriteStream(fileToPrintPath));
- stream.on('finish', function () {
- nw.Window.open('http://localhost:37339/' + filename, {
- show: true,
- new_instance: false
- }, function (win) {
- win.maximize();
- win.on('loaded', function () {
- try {
- win.print({
- autoprint: false,
- landscape: true,
- headerFooterEnabled: true,
- headerString: 'Compass snapshot: ' + filename,
- footerString: ''
- });
- console.log('tried');
- fs.unlinkSync(fileToPrintPath);
- win.close();
- } catch (exception) {
- console.log('print exception', exception);
- }
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement