1

I found this fiddle but it doesn't support CSS.

Is there a way to tweak jsPDF to customize the css of the tables and lists? I tried to use addHTML but looks like it is not working for me if I try to pass in the id of a certain element and not the entire body of the html.

    function demoFromHTML() {
    var pdf = new jsPDF('p', 'pt', 'letter');
    var source = $('#customers')[0];
    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: 60,
        left: 10,
        width: 700
    };
    // 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('Test.pdf');
    }, margins);
}

Or maybe you have a suggestion for a better plugin similar to this that i can use. In my application i am dynamically creating a div full of information such as table and lists that are required to be put into pdf before user can print Thanks

0 Answers0