我无法使用jsPDF将某些特殊字符(塞尔维亚拉丁字母)导出到PDF。
我已经应用了转换后的字体并设法使其适用于简单文本,但是当导出具有id =“ exportContent”的div元素的内容时却无法使其正常工作。
这是可以运行并导出带有特殊字符的简单文本的代码:
function demoFontTypes() {
var doc = new jsPDF();
doc.setFont('ARIALUNI'); // set font
doc.setFontSize(10);
doc.text('žsćdšclsdpžcslcpsžclpsdpžclsdžpclsdžclpsć', 10, 10);
doc.save('test.pdf');
}
我正在尝试使用此代码导出div元素的内容,但无法使其导出这些字符(žćđšč)
$(document).ready(function() {
$(".btnPDF").click(function() {
var doc = new jsPDF("p", "pt", "A4");
var source = $("#exportContent")[0];
var margins = {
top: 30,
bottom: 60,
left: 50,
width: 522
};
doc.setFont('ARIALUNI'); // set font
doc.fromHTML(
source, // HTML string or DOM elem ref.
margins.left, // x coord
margins.top, {
// y coord
width: margins.width // max width of content on PDF
},
function(dispose) {
// dispose: object with X, Y of the last line add to the PDF
// this allow the insertion of new lines after html
doc.save("Test.pdf");
},
margins
);
});
});
我需要能够导出带有特殊字符(塞尔维亚语拉丁语)的div元素的内容