簡體   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