Reputation: 554
I need to print my html contet and text together, I tried with the below code, but the text that am added is not printing in the PDF. Its only print the html contents. Please help me to solve this issue....
pdf = new jsPDF('l', 'mm', 'ledger'),
specialElementHandlers = {
'#editor': function( element, renderer ) {
return true;
}
};
pdf.fromHTML(
$('#customers').get(0) // HTML element
, 15 // x coord
, 0.5 // y coord
, {
'width': 3000 // was 7.5, max width of content on PDF
, elementHandlers: specialElementHandlers
}
);
pdf.text(35, 25, "test");
pdf.save( filename );
});
Upvotes: 1
Views: 8565
Reputation: 71
you must use the full sintax of function:
doc.fromHTML(HTML, x, y, settings, callback, margins);
Using callback you can add a function that executes on fromHtml complete.
In your code:
pdf = new jsPDF('l', 'mm', 'ledger'),
specialElementHandlers = {
'#editor': function( element, renderer ) {
return true;
}
};
pdf.fromHTML(
$('#customers').get(0) // HTML element
, 15 // x coord
, 0.5 // y coord
, {
'width': 3000 // was 7.5, max width of content on PDF
, elementHandlers: specialElementHandlers
},
myfunc,
{
top : 25,
bottom : 25
}
);
function myfunc(){
pdf.text(35, 25, "test");
pdf.save( filename );
}
Upvotes: 7
Reputation: 755
I think your missing the syntax here What you have done here pdf.text(35, 25, "test"); Instead use this: pdf.text("test",35, 25); (Where the 35 stands X axis an 25 stands Y axis in pdf document).
Upvotes: 3