[英]jsPDF convert html to pdf: utf-8 works only with text, but not html
I need to convert html to pdf with jsPDF.我需要使用 jsPDF 将 html 转换为 pdf。 It contains UTF-8 symbols (cyrillic).它包含 UTF-8 符号(西里尔文)。 I used fontconverter to generate js-file for my custom font as written here: https://github.com/MrRio/jsPDF我使用 fontconverter 为我的自定义字体生成 js 文件,如下所示: https : //github.com/MrRio/jsPDF
So now example with text works like a charm.所以现在文本示例就像一个魅力。
var pdf = new jsPDF('p', 'pt', 'letter');
doc.setFont('PTSans');
doc.setFontSize(10);
doc.text("А ну чики брики и в дамки!", 10, 10);
And example with html ignores my custom font and exports incorrect symbols.和 html 示例忽略我的自定义字体并导出不正确的符号。
var pdf = new jsPDF('p', 'pt', 'letter');
doc.setFont('PTSans');
doc.setFontSize(10);
pdf.html( "<html>А ну чики брики и в дамки!</html>", { callback: function (pdf) {
var iframe = document.createElement('iframe');
iframe.setAttribute('style', 'position:absolute;right:0; top:0; bottom:0; height:100%; width:500px');
document.body.appendChild(iframe);
iframe.src = pdf.output('datauristring');
}
});
What I need to do to export html to pdf with unicode symbols?我需要做什么才能使用 unicode 符号将 html 导出为 pdf?
I have not found how to solve this problem and created issue on jspdf github.我还没有找到如何解决这个问题并在 jspdf github 上创建问题。 And I've found that pdfmake.org correctly works with utf-8 symbols, so if you have same problems, use pdfmake.而且我发现 pdfmake.org 可以正确使用 utf-8 符号,因此如果您遇到相同的问题,请使用 pdfmake。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.