You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was searching for answers all over github and stackexchange and could not find a working solution for this issue.
I try to embed font FiraSans. However, it seems to embedded incompletely. Only a view characters are actually displayed correctly. I can copy even the "invisible" characters to any text editor and I receive the correct text.
I tried three approaches:
The one from the examples. However I think this is a bad example because it uses Roboto, which seems to be included anyway and works.
The one from the server-side dev-playground. I thought this might solve path issues because I am working a windows platform, but it didn't work.
The client side vs_fonts.js approach which is propoped in the github issues.
None of them worked for me. They actually all create the same result, which looks like that:
I can exclude the following causes:
incorrect path, it would throw errors. already tried out.
corrupted ttf files, as i tried it with various fonts and sources
Does anyone have a solution for this?
My code:
constpdfMakePrinter=require('pdfmake/src/printer');constfs=require('fs')varpath=require('path');constdocDefinition={content: ['abcdefghijklmnopqrstuvwABCDEFGHIJKLMNOPQRSTUVW0123456789',],defaultStyle: {font: 'FiraSans'}};vargeneratePdf=function(docDefinition,callback){try{constfontDescriptors={FiraSans: {normal: './fonts/FiraSans-Regular.ttf',//normal: path.join(__dirname, '..', 'pdf-generate', '/fonts/FiraSans-Regular.ttf'),//normal: new Buffer(require('pdfmake/build/vfs_fonts.js').pdfMake.vfs['FiraSans-Regular.ttf'], 'base64'),bold: '/fonts/FiraSans-Medium.ttf',italics: '/fonts/FiraSans-Italic.ttf',bolditalics: '/fonts/FiraSans-MediumItalic.ttf'}};constprinter=newpdfMakePrinter(fontDescriptors);constdoc=printer.createPdfKitDocument(docDefinition);doc.pipe(fs.createWriteStream('docs/filename.pdf').on("error",(err)=>{console.error(err.message);}));doc.on('end',()=>{console.log("PDF successfully created and stored");});doc.end();}catch(err){throw(err);}};generatePdf(docDefinition,(response)=>{res.setHeader('Content-Type','application/pdf');res.send(response);// Buffer data});
The text was updated successfully, but these errors were encountered:
This PR foliojs/fontkit#191 solves the issue in way, that the server side embedding works with the code below. There are no other workarounds or anything needed.
I was searching for answers all over github and stackexchange and could not find a working solution for this issue.
I try to embed font FiraSans. However, it seems to embedded incompletely. Only a view characters are actually displayed correctly. I can copy even the "invisible" characters to any text editor and I receive the correct text.
I tried three approaches:
None of them worked for me. They actually all create the same result, which looks like that:
![image](https://user-images.githubusercontent.com/7767250/53650979-07568a00-3c46-11e9-96eb-9f02dfb2080d.png)
I can exclude the following causes:
Does anyone have a solution for this?
My code:
The text was updated successfully, but these errors were encountered: