I am working on an electron.js application where I am creating PDFs using jsPDF on the server side.
Its working as expected except the addimage property. It creates a rectangular black box in place of image in PDF.
global.PNG = require('png-js');
global.window = {document: {createElementNS: () => {return {}} }};
global.navigator = {};
global.atob = require('atob');
const jsPDF = require('jspdf');
let doc = new jsPDF();
let imgData = 'data:image/jpeg;base64,.................'
doc.addImage(imgData, 'PNG', 80, 10,50,15);
let data = doc.output();
fs.writeFileSync(folderPath, data);
delete global.window;
delete global.navigator;
delete global.btoa;
The same base64 image works in client side jsPDF, but not in node.js.