我在AngularJS和电子中使用图书馆的AngularJS有问题。pdf保存为空白。
守则是:
.service('PDFService', function() {
this.createPdfOne = function(data) {
const {dialog} = require('electron').remote;
const choice = dialog.showOpenDialog({ properties: [ 'createDirectory', 'openDirectory']});
var docDefinition = {
content: [
'First paragraph',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines'
]
};
var fs = require('fs');
pdfMake.createPdf(docDefinition).getBuffer(function(result) {
fs.writeFileSync(choice + '/sample.pdf', result);
});
};
});更新:修复问题
我用:
pdfMake.createPdf(docDefinition).download()而不是:
var fs = require('fs');
pdfMake.createPdf(docDefinition).getBuffer(function(result) {
fs.writeFileSync(choice + '/sample.pdf', result);
});https://stackoverflow.com/questions/41861759
复制相似问题