大家好,我在使用html2canvas和js pdf将vue js组件转换为pdf时遇到了麻烦。我在我的应用程序上启用了翻译。对于英语,转换后的pdf效果很好。但是孟加拉语的字体坏了。找不到解决孟加拉字体问题(Unicode字体)的帮助。我添加了将选定的tom转换为pdf的功能。
pdfDownload(){
var HTML_Width = $("#taxForm").width();
var HTML_Height = $("#taxForm").height()-100;
var top_left_margin = 10;
var PDF_Width = 1050;
var PDF_Height = 1850;
var canvas_image_width = HTML_Width;
var canvas_image_height = HTML_Height;
var totalPDFPages = Math.ceil(HTML_Height/PDF_Height)-2;
html2canvas($("#taxForm")[0],{allowTaint:false}).then(function(canvas) {
document.body.appendChild(canvas);
canvas.getContext('2d');
var imgData = canvas.toDataURL("image/jpeg", 1.0);
canvas.font = "arial";
var pdf = new jsPDF('p', 'pt', [PDF_Width, PDF_Height]);
pdf.addImage(imgData, 'JPG', top_left_margin, top_left_margin,canvas_image_width,canvas_image_height);
for (var i = 1; i <= totalPDFPages; i++) {
pdf.addPage(PDF_Width, PDF_Height);
pdf.addImage(imgData, 'JPG', top_left_margin, -(PDF_Height*i)+(top_left_margin*4),canvas_image_width,canvas_image_height);
}
pdf.save("Tax-Return.pdf");
});
},
},