[英]jsPDF cannot set font family
I cannot change the font family. 我无法改变字体系列。 This is directly off jsPDF website : 这是直接关闭jsPDF 网站 :
var doc = new jsPDF();
doc.text(20, 20, 'This is the default font.');
doc.setFont("courier");
doc.setFontType("normal");
doc.text(20, 30, 'This is courier normal.');
doc.setFont("times");
doc.setFontType("italic");
doc.text(20, 40, 'This is times italic.');
doc.setFont("helvetica");
doc.setFontType("bold");
doc.text(20, 50, 'This is helvetica bold.');
doc.setFont("courier");
doc.setFontType("bolditalic");
doc.text(20, 60, 'This is courier bolditalic.');
But here is what is printed for: 但这里是打印的:
These are all just times
font. 这些都是times
字体。 Why is the font family not changing? 为什么字体系列不会改变?
Actually you can use 其实你可以使用
doc.addFont()
For example: 例如:
doc.addFont('ArialMS', 'Arial', 'normal');
doc.setFont('Arial');
doc.text(50,150,'Hello World');
我遇到了同样的问题我提出了最好的解决方案它是使用最新版本的库使用jspdf.debug.js文件用法你可以在这里找到它们: https ://cdnjs.com/libraries/jspdf
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.