简体   繁体   中英

How to use custom font in jsPDF to create pdf?

I'm trying to create a simple pdf doc using javascript. I found jsPDF but I don't figure out how to use "CALIBRI" font text. Is it possible?

Unfortunaletly I don't think that is possible. The documentation states that you can use getFontList() to see what fonts are available. As you can see below it returns courier , times and helvetica .

 var doc = new jsPDF(); var elem = document.getElementById('fonts'); elem.innerText = Object.keys(doc.getFontList()).join(', '); 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.1.135/jspdf.min.js"></script> <ul id="fonts"></ul> 

The capitalized versions of the fonts returned seem to be only for ease of use and are the same as the none-capitalized fonts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM