I'm currently trying to use PDFMake on the server side with Node.js. Unfortunately, I'm getting an error related to FS that is reading:
fs is not defined at Object.module.exports.fontkit.openSync
Below is my code:
const fs = require('fs');
const PdfPrinter = require('pdfmake/src/printer');
// The Roboto file is in the root of the application like others have mentioned to do
const fontDescriptors = {
Roboto: {
normal: './fonts/Roboto-Regular.ttf',
bold: './fonts/Roboto-Medium.ttf',
italics: './fonts/Roboto-Italic.ttf',
bolditalics: './fonts/Roboto-MediumItalic.ttf',
},
};
const printer = new PdfPrinter(fontDescriptors);
const pdfDoc = printer.createPdfKitDocument(reportDefinition);
pdfDoc.pipe(fs.createWriteStream('basics.pdf')).on('finish', function () {
console.log('pdf success');
});
pdfDoc.end();
To note: I'm using this inside an Electron app, so the browser is Chromium.
Hello,
I'm currently trying to use PDFMake on the server side with Node.js. Unfortunately, I'm getting an error related to FS that is reading:
fs is not defined at Object.module.exports.fontkit.openSync
Below is my code:
To note: I'm using this inside an Electron app, so the browser is Chromium.
Any help would be much appreciated.
Thank you.