Question

Hi I want to render a HTML generated invoice with jsPDF, but when I try to render an error occurs saying me

Uncaught TypeError: Cannot read property 'length' of undefined jspdf.plugin.from_html.js:233

tried to fix it by my self... unsuccessful...

I have the plugins jspdf.plugin.standard_fonts_metrics, jspdf.plugin.split_text_to_size, jspdf.plugin.from_html bound in.

Here the code I use for render:

var doc = new jsPDF('p', 'in', 'letter');
var source = $('#invoiceTemplate');

doc.fromHTML(
    source,
    0.5,
    0.5,
    {
        'width': 7.5,
        'elementHandlers': {}
});

doc.output('dataurlnewwindow');

I think the problem starts in line 223 of the fromHTML plugin with the childNodes thing...

cns = element.childNodes;

Thank you in advance!

Était-ce utile?

La solution

Solved it by my own.

var source = $('#invoiceTemplate');

should be

var source = document.getElementById('invoiceTemplate');

And everything works fine!

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top