Is it possible to include custom fonts in jsPDF ?
With the basic library, if I console log \'doc.getFontList()\' I get:
Courier, Helvetica, Ti
It seems to be a lot easier with the latest version of jsPDF (1.5.3):
If you look in the folder jsPDF-master
> fontconverter
, there's a file fontconverter.html
. Open in your browser and use the Browse...
button to navigate to, and select your .ttf
font file.
Click 'Create'.
The page will offer a "download" to be saved. This will produce a .js
file called [something like] RopaSans-Regular-normal.js
. This needs to be included in your page producing the PDF's. Personally, I've done it in the main page's header (and please note the order of the script
s):
Now in your PDF generation method in js:
doc.setFont('RopaSans-Regular');
doc.setFontType('normal');