Generate pdf from HTML in div using Javascript

前端 未结 12 1336
你的背包
你的背包 2020-11-22 06:10

I have the following html code:



    
        

don\'t print th

12条回答
  •  时光说笑
    2020-11-22 06:29

    I was able to get jsPDF to print dynamically created tables from a div.

    $(document).ready(function() {
    
            $("#pdfDiv").click(function() {
    
        var pdf = new jsPDF('p','pt','letter');
        var specialElementHandlers = {
        '#rentalListCan': function (element, renderer) {
            return true;
            }
        };
    
        pdf.addHTML($('#rentalListCan').first(), function() {
            pdf.save("caravan.pdf");
        });
        });
    });
    

    Works great with Chrome and Firefox... formatting is all blown up in IE.

    I also included these:

    
        
        
        
        
        
        
        
        
    
        
        
        
        
    

提交回复
热议问题