Alp*_*eek 5 html javascript css pdf jspdf
我想使用 javascript 将 html 表打印到 pdf 文件。为此,我使用 jspdf lib。我创建了这个例子
$(document).on('click', '#pdfbutton', function(event) {
var pdf = new jsPDF('p', 'pt', 'letter'),
source = $('#printit')[0],
specialElementHandlers = {
'#bypassme': function(element, renderer) {
return true
}
}
var margins = {
top: 20,
bottom: 30,
left: 20,
width: 700
};
pdf.fromHTML(
source // HTML string or DOM elem ref.
, margins.left // x coord
, margins.top // y coord
, {
'width': margins.width // max width of content on PDF
,
'elementHandlers': specialElementHandlers
},
function(dispose) {
pdf.save('Test.pdf');
},
margins
)
});
Run Code Online (Sandbox Code Playgroud)
https://jsfiddle.net/6hngty42/
现在,当我打印 pdf 时,它向我显示 html 表格的不同格式。
如何将 html 和 css 保存为 pdf?
或者
如何使用 jspdf 格式化表格?
或者
是否有任何其他js库可以使用css离线打印pdf到html(我检查了cloudformatter,但它可以在线工作)?
仅供参考:我还检查了其他示例,但没有一个解决方案对我有用。
| 归档时间: |
|
| 查看次数: |
957 次 |
| 最近记录: |