Forum Discussion
Storyline 360 - Generating a PDF Certificate using JavaScript
Hello, has anyone had luck adding a font to pdfMake for the certificate? I have been struggling with this as Roboto is the default. I found the pdfMake documentation and many js articles on how to do so but can't get a font implemented. I have converted a fontset to base 64, tried adjusting the "vfs_fonts.js" file as well as creating a new class in the user.js file and referencing in my text fields but not having success. Thanks!
- SanduniFernando5 years agoCommunity Member
I have replaced the default Roboto font with my preferred font and it worked for me. Did you update the 'pdfmake.js' file as well?
Do you try to have multiple fonts in the PDF or just change the default font? I haven't had multiple fonts in "vfs_fonts.js" file but replacing the font worked for me.
- JeffForrer5 years agoCommunity Member
Thanks, I did not try to replace it, I do have two fonts I need to use, so I added them to the vfs file. I know Roboto is listed as default in pdfmake.js, but I did not make a change there. Thank you for responding.
- SanduniFernando5 years agoCommunity Member
Though I haven't used multiple fonts, the following links may be useful:
https://pdfmake.github.io/docs/fonts/custom-fonts-client-side/
https://github.com/bpampuch/pdfmake/issues/673
I think you have to update"pdfmake.js" as well. Make sure to include this in index.html file as the "pdfmake.min.js" is called in the default file.
- JeffForrer5 years agoCommunity Member
Hello, I may just try to go with only one font. I am trying to swap out Helvetica for Roboto. Did you create base 64 versions of the font for the vfs fonts.js file and replace the Roboto ones that were there? Thx.
- SanduniFernando5 years agoCommunity Member
Yes, I just converted the font to base64 using https://www.base64encode.org/enc/font/, and replaced the Roboto values in between " " in vfs_fonts.js file. If you want the bold and italic fonts, you can do the same or if you need only the regular style, you can just remove them from the vfs_fonts. js file (Roboto-italic, Roboto-medium and Roboto medium italic)