I'm using pdfMake for generating PDF in ionic/angular. It's working fine with android but getting error in iOS when loading font dynamically.
I'm loading font in this way
generatePDF(pdfInstant: any, content: any) {
pdfInstant.fonts = {
common: {
normal: `${window.location.origin}/assets/fonts/pdf/FreeSerif.ttf`,
bold: `${window.location.origin}/assets/fonts/pdf/FreeSerif.ttf`,
italics: `${window.location.origin}/assets/fonts/pdf/FreeSerif.ttf`,
bolditalics: `${window.location.origin}/assets/fonts/pdf/FreeSerif.ttf`,
},
};
content['defaultStyle'] = {
font: 'common'
};
pdfInstant.createPdf(content).getBase64((r: any) => {
this.utilService.sharePDF(new Date().getTime() / 1000 + '.pdf', r);
});
}
Error I'm getting is:
⚡️ [error] - ERROR Error: Uncaught (in promise): File 'capacitor://localhost/assets/fonts/pdf/FreeSerif.ttf' not found in virtual file system