HTML到PDF - jspdf在表的情况下忽略第二列

时间:2016-09-23 07:40:29

标签: javascript html pdf jspdf

我有div,其中包含一些数据和table。我现在面临的问题是jspdf忽略了表的第二列,只打印了每行的第一列。以下是HTML和JS

<div id="myDiv">
    <p id="bypassme">Some text</p>
    <p>Some more text</p>
    <table>
        <tr>
            <td>First</td>
            <td>Second</td>
        </tr>
        <tr>
            <td>Third</td>
            <td>Fourth</td>
        </tr>
    </table>
</div>


<script type="text/javascript">
    var doc = new jsPDF('p', 'pt', 'letter');
    var html = $('#myDiv').html();      
    var specialElementHandlers = {
         '#bypassme': function(element, renderer){
             return true;
          }
    };
    doc.fromHTML(html,10,10, {
            'width': 500,
            'elementHandlers': specialElementHandlers
         });
    doc.save("Test.pdf");
</script>

页面上显示的内容:

Some text
Some more text
+-------+--------+
| First | Second |
+-------+--------+
| Third | Fourth |
+-------+--------+

实际输出

Some more text
First
Third

预期输出

Some more text
First     Second
Third     Fourth

0 个答案:

没有答案