Custom font faces in jsPDF?

后端 未结 6 707
無奈伤痛
無奈伤痛 2020-12-08 15:30

Is it possible to include custom fonts in jsPDF ?

With the basic library, if I console log \'doc.getFontList()\' I get:

Courier, Helvetica, Ti

6条回答
  •  既然无缘
    2020-12-08 15:41

    The easiest way that I have found by far is using the jspdf-customfonts package. Simply install the package by npm i jspdf-customfonts then add the following files in the head tag of your index.html for default configurations

    script src="https://unpkg.com/jspdf@latest/dist/jspdf.min.js"> 
     
     
    

    Now you can download the ttf file of whichever font you want. Then go to this site, select your font and copy the code, and you are done!

提交回复
热议问题