这是相关代码。
let Name = moment().unix() + ".pdf";
var html = fs.readFileSync('./test/businesscard.html', 'utf8');
let filename = "C:\\App\\Register\\pdf\\" + Name;
pdf.create(html, options).toFile(filename, function (err, response) {
if (err) {
res.status(403).json({
message: 'error'
})
} else {
res.status(200).json({
message: 'success'
})
}
}它在开发版本上运行良好,并创建PDF文件。但是当我创建一个电子构建包时,pdf文件没有生成.
如果有任何解决方案可用,这将是一个很大的帮助。
发布于 2019-04-15 10:09:18
您应该使用app.getAppPath()对打包的应用程序使用绝对路径。
改换这条线
var html = fs.readFileSync('./test/businesscard.html', 'utf8');借此
var html = fs.readFileSync(path.join(app.getAppPath(), '/test/businesscard.html', 'utf8'));别忘了再加上
const path = require('path')
const app = require('electron').remote.apphttps://stackoverflow.com/questions/55399501
复制相似问题