I have a save dialog in an electron app. At the moment, when a user clicks save it will save with the default name and file extension foo.pdf.
When the name is changed, the file extension isn't added.
Is there a way to make sure that the .pdf file extension is added to all file names?
document.getElementById("pdf-btn").onclick = function() {
var webv = document.getElementById('appview');
dialog.showSaveDialog({
defaultPath: '~/foo.pdf'
}, function(file_path) {
if (file_path) {
webv.printToPDF({}, function(err, data) {
if (err) {
dialog.showErrorBox('Error', err);
return;
}
fs.writeFile(file_path, data, function(err) {
if (err) {
dialog.showErrorBox('Error', err);
return;
}
// addext = file_path + ".pdf";
//
// save_pdf_path = addext;
save_pdf_path = file_path;
var message = "<p> Write PDF file: " + save_pdf_path + " successfully!</p>";
console.log(message);
});
});
}
});
}