admin管理员组文章数量:1345722
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 );
});
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 );
});
Share
Improve this question
asked Feb 10, 2015 at 11:31
Syam kumar KKSyam kumar KK
5542 gold badges6 silver badges32 bronze badges
2 Answers
Reset to default 7you 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 plete.
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 );
}
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).
本文标签: javascriptHow can i create pdf with jspdf from html and textStack Overflow
版权声明:本文标题:javascript - How can i create pdf with jspdf from html and text? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743814642a2543691.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论