I'd like to know how to open in my operating system a .pdf with Node-Webkit and PDFKIT.
The Node-Webkit app create the .pdf at the root of the project, I just would like to open and print it...
var pdf = require('pdfkit');
var fs = require('fs');
( function($){
$(document).ready( function(){
$('#form-quote').on('submit', function(e){
e.preventDefault();
var doc = new pdf();
doc.pipe(fs.createWriteStream('quote.pdf'));
doc.fontSize(20).text("test", 50, 400);
doc.end();
// Open the .pdf here using the operating system of the user
});
});
})(jQuery);
Use the Shell component as follows:
// Load native UI library.
var gui = require('nw.gui');
// Open URL with default browser.
gui.Shell.openExternal('https://github.com/rogerwang/node-webkit');
// Open a text file with default viewer.
gui.Shell.openItem('quote.pdf');
// Open a file in file explorer.
gui.Shell.showItemInFolder('quote.pdf');
Check the corresponding Node-Webkit reference for more information.