[英]jsPDF && jsPDF AutoTable print spcial chars to PDF
在发布 1.4.0 版本后,jsPDF 最终支持编码变音符号字符,但以一种非常奇怪的方式,imo。
C:\\Windows\\Fonts\\Calibri
并将.ttf
字体文件复制到桌面。 import { jsPDF } from "jspdf" var font = 'AAEAAAAWAQQAAB...=='; var callAddFont = function () { this.addFileToVFS('calibri-normal.ttf', font); this.addFont('calibri-normal.ttf', 'calibri', 'normal'); }; jsPDF.API.events.push(['addFonts', callAddFont]);
this.addFont('calibri-normal.ttf', 'calibri', 'normal');
的第二个字符串将是您的字体名称。 记住它。
import '../utils/calibri-normal';
jsPDF
对象并设置字体的位置: const doc = new jsPDF('p', 'pt', 'a4'); doc.setFont("calibri"); // <-- place here your font name, which you remeber before //... doc.save('file001.pdf');
doc.autoTable({ head: [['Column1', 'Column2', 'Column3']], body: someDataRows, styles: { font: 'calibri', // <-- place name of your font here fontStyle: 'normal', }, margin: { bottom: 60 } });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.