pdfjs 字体新增,在jspdf中添加自定义字体

i want to use custom font such as 'Comic Sans MS' or 'Calibri' font in jsPDF.

i have found similar question here, but mine is not working.

i already added the latest jspdf. and my code is like below :

var doc = new jsPDF('p','mm','a4');

doc.addFont('ComicSansMS', 'Comic Sans', 'normal','StandardEncoding');

doc.setFont('Comic Sans');

doc.text(10, 10, "Lorem ipsum dolor sit amet!");

doc.output('dataurl');

but the pdf result's font is still the default font ( not comic sans ).

and there is no error. Please help...

解决方案

i have found the solution,

don't use the jspdf.js, but use the debug.jspdf.js

and after that add this code in the debug.jspdf.js

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

addFont(postScriptName, fontName, fontStyle, 'StandardEncoding');

};

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值