-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Closed
Labels
Description
I get this error when I try to call fromHTML on my pdf object:
Uncaught TypeError: Cannot read property 'length' of null jspdf.debug.js:2875
ResolveUnitedNumber jspdf.debug.js:2875
GetCSS jspdf.debug.js:2895
DrillForContent jspdf.debug.js:2986
done jspdf.debug.js:3041
loadImgs jspdf.debug.js:3058
process jspdf.debug.js:3073
jsPDFAPI.fromHTML jspdf.debug.js:3269
PaneView.extend.createPdf ReportsPage.js:349
My code (ReportsPage.js):
createPdf : function( $obj ) {
var _this = this,
d = new Date().toISOString().slice(0, 19).replace(/-/g, ""),
filename = 'report_' + d + '.pdf',
pdf = new jsPDF('p', 'in', 'letter'),
specialElementHandlers = {
'#editor': function( element, renderer ) {
return true;
}
};
pdf.fromHTML(
$obj.get(0) // HTML element
, 0.5 // x coord
, 0.5 // y coord
, {
'width': 170 // was 7.5, max width of content on PDF
, elementHandlers: specialElementHandlers
}
);
pdf.save( filename );
},
The HTML being passed to fromHTML (with added indents and spaces to avoid Markdown rendering the HTML):
< div>
< h1>Meow< /h1>
< table>< thead>< tr>
< th>Header 0< /th>< th>Header 1< /th>< th>Header 2< /th>< th>Header 3< /th>
< /tr>< /thead>
< tbody>
< tr>< td>0.0< /td>< td>0.1< /td>< td>0.2< /td>< td>0.3< /td>< /tr>
< tr>< td>1.0< /td>< td>1.1< /td>< td>1.2< /td>< td>1.3< /td>< /tr>
< tr>< td>2.0< /td>< td>2.1< /td>< td>2.2< /td>< td>2.3< /td>< /tr>
< tr>< td>3.0< /td>< td>3.1< /td>< td>3.2< /td>< td>3.3< /td>< /tr>
< tr>< td>4.0< /td>< td>4.1< /td>< td>4.2< /td>< td>4.3< /td>< /tr>
< /tbody>< /table>
< /div>
Using latest version of jspdf.debug.js from this repo, and latest Chrome on Windows 7.