سؤال

I am using JSPDF library to load the HTML page into PDF, I tried with sample small HTML page, it worked well but in my Application its not displaying the complete HTML page and not loading css styles. Please help me where i went wrong.

$(document).ready(function(){ 
        var specialElementHandlers = {
            '#editor': function (element,renderer) {
                return true;
            }
        };
     $('#cmd').click(function () {
            var doc = new jsPDF();
            doc.getFontList();
            doc.fromHTML($('#target').html(), 15, 15, {
                'width': 170,
                height: 30,

                'elementHandlers': specialElementHandlers
            });
            doc.save('sample-file.pdf');
        });  
    });
هل كانت مفيدة؟

المحلول

  • the right syntax is doc.fromHTML($('#target').get(0), ...
    • jspdf can't render your css
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top