Reputation: 83
Here are the relevant code.
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'
})
}
}
it's working fine on dev version and create PDF file. But when i create a electron build-pack, the pdf file not generated.
If any solution is available then it will be a big help
Upvotes: 0
Views: 1481
Reputation: 467
You should use an absolute path for packaged application by using app.getAppPath().
Remplace this line
var html = fs.readFileSync('./test/businesscard.html', 'utf8');
By this
var html = fs.readFileSync(path.join(app.getAppPath(), '/test/businesscard.html', 'utf8'));
And not forgot to add
const path = require('path')
const app = require('electron').remote.app
Upvotes: 1