简体   繁体   中英

Need help getting jspdf to render html to PDF

I'm trying to get jspdf to work. Nothing is happening after clicking the button in my fiddle. Here is the jsfiddle ( https://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 . You also forgot to close the style attribute in <table>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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