300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > jspdf添加宋体 jsPDF中的自定义字体?

jspdf添加宋体 jsPDF中的自定义字体?

时间:2019-06-19 04:38:14

相关推荐

jspdf添加宋体 jsPDF中的自定义字体?

Is it possible to include custom fonts in jsPDF ?

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

Courier, Helvetica, Times, courier, helvetica, times

But, say I want to use Comic Sans ( not that I would ;o) ) can it be done ?

Even better, could I use a font is locally stored and has been declared in the site with @font-face ?

解决方案

I found this was possible by modifying jsPDF.js to expose the existing addFont method in the public API.

In jsPDF.js, look for:

//---------------------------------------

// Public API

Add the following:

API.addFont = function(postScriptName, fontName, fontStyle) {

addFont(postScriptName, fontName, fontStyle, StandardEncoding);

};

I put this method near other font methods for clarity - API.set

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。