Exporting HTML table to PDF with its format with jsPDF

一个人想着一个人 提交于 2019-12-11 12:58:29

问题


I'm using jspdf to export a table from html to PDF, however my table looks messed up:

This is my table in html:

And lastly, this is my code:

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

    source = jQuery('#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: 30,
        bottom: 60,
        left: 60,
        width: 700
    };

    pdf.fromHTML(
            source, 
            margins.left, 
            margins.top, {
                'width': margins.width, 
                'elementHandlers': specialElementHandlers
            },
    function(dispose) {
        pdf.save('Test.pdf');
    }
    , margins);
}

I'm really confused of why it isn't working properly, I've tried a ton of things but it seems this can only be fixed through jspdf documentation which is almost nonexistant when it comes to exporting tables, I'm REALLY desperate, any help is appreciated.

Thanks :)

来源:https://stackoverflow.com/questions/24414643/exporting-html-table-to-pdf-with-its-format-with-jspdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!