繁体   English   中英

尝试使用希伯来语字符从html导出PDF

[英]Trying to export PDF from html with hebrew charactars

我正在尝试将表格导出为PDF文件,但是如果有希伯来语字符,它将不会显示它们的正确性。

我试图在HEAD部分中添加UTF-8的mata标签,并且还添加了php header'Content-Type:text / html; 字符集= UTF-8'

function demoFromHTML() {
    var pdf = new jsPDF('p', 'pt', 'letter');

    source = $('#customers')[0];

    specialElementHandlers = {
        // element with id of "bypass" - jQuery style selector
        '#bypassme': function (element, renderer) {
            // true = "handled elsewhere, bypass text extraction"
            return true
        }
    };
    margins = {
        top: 80,
        bottom: 60,
        left: 10,
        width: 300
    };
    pdf.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
        'elementHandlers': specialElementHandlers
    },

    function (dispose) {
        pdf.save('Test.pdf');
    }, margins);
}

我认为您可以使用dir =“ rtl”以获得更多信息,请通过以下链接查看

https://developers.itextpdf.com/ja/node/2079

您正在将特定元素的HTML导出到PDF文件,该HTML不包含任何标题信息,因此您应先添加此信息,然后再将其导出为pdf。 在这里,您可以看到一个如何添加utf-8信息的示例。

pdf.fromHTML(
    '<html><head><meta charset="utf-8" /><body>' + source + '</body></html',
    margins.left, // x coord
    margins.top, { // y coord
        'width': margins.width, // max width of content on PDF
        'elementHandlers': specialElementHandlers
    }
    ...
);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM