我需要一起打印我的html语句和文本,我尝试使用下面的代码,但添加的文本不是在PDF中打印.它只打印html内容.请帮我解决这个问题....
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 );
});
Run Code Online (Sandbox Code Playgroud)
小智 7
你必须使用函数的完整sintax:
doc.fromHTML(HTML, x, y, settings, callback, margins);
Run Code Online (Sandbox Code Playgroud)
使用回调,您可以添加一个在fromHtml完成时执行的函数.
在你的代码中:
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 );
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2760 次 |
| 最近记录: |