Javascript 如何从HTML表格生成PDF?

Javascript 如何从HTML表格生成PDF?,javascript,angularjs,pdf,pdf-generation,Javascript,Angularjs,Pdf,Pdf Generation,这是我的代码,我已经收到了所有的行,但是设计问题没有正确显示。第二页混合了页眉和第11行 $scope.generatePDF = function () { var pdf = new jsPDF('p', 'pt', 'letter'); // source can be HTML-formatted string, or a reference // to an actual DOM element from which the text will be scr

这是我的代码,我已经收到了所有的行,但是设计问题没有正确显示。第二页混合了页眉和第11行

  $scope.generatePDF = function () {
    var pdf = new jsPDF('p', 'pt', 'letter');
    // source can be HTML-formatted string, or a reference
    // to an actual DOM element from which the text will be scraped.
    source = $('#div_print')[0];

    // we support special element handlers. Register them with jQuery-style 
    // ID selector for either ID or node name. ("#iAmID", "div", "span" etc.)
    // There is no support for any other type of selectors 
    // (class, of compound) at this time.
    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: 10,
        left: 10,
        width: 800
    };
    // all coords and widths are in jsPDF instance's declared units
    // 'inches' in this case
    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) {
        // dispose: object with X, Y of the last line add to the PDF 
        //          this allow the insertion of new lines after html
        pdf.save('PriceList.pdf');
    }, margins);
}
在这里,我使用:

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.4/jspdf.min.js"></script>  
<script src="../Scripts/Pdf.js"></script>


您是否发现任何控制台错误?如果没有,如果您在
pdf.save('PriceList.pdf')上设置断点
是否填充了
pdf
对象?我没有收到任何错误