简体   繁体   English

需要帮助让jspdf将html呈现为PDF

[英]Need help getting jspdf to render html to PDF

I'm trying to get jspdf to work. 我想让jspdf工作。 Nothing is happening after clicking the button in my fiddle. 点击我小提琴中的按钮后什么也没发生。 Here is the jsfiddle ( https://jsfiddle.net/light22/68h81owf/ ). 这是jsfiddlehttps://jsfiddle.net/light22/68h81owf/ )。 Thanks in advance for helping me. 在此先感谢您的帮助。

Here is the script I am using: 这是我正在使用的脚本:

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

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

        specialElementHandlers = {

            '#bypassme': function (element, renderer) {
                return true
            }
        };
        margins = {
            top: 80,
            bottom: 60,
            left: 40,
            width: 522
        };

        pdf.fromHTML(
            source, 
            margins.left, 
            margins.top, { 
                'width': margins.width, 
                'elementHandlers': specialElementHandlers
            },

            function (dispose) {

                pdf.save('download.pdf');
            }, margins
        );
    }
</script>

After clicking the button in your jsfiddle, an error is thrown: ReferenceError: demoFromHTML is not defined . 单击jsfiddle中的按钮后,将引发错误: ReferenceError: demoFromHTML is not defined You also forgot to close the style attribute in <table> 您还忘记关闭<table>的style属性

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

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