从横向格式的HTML页面制作PDF
Make a PDF from a HTML page in landscape format
我需要制作一个横向格式的PDF。
<script type="text/javascript">
$(function () {
var doc = new jsPDF();
var specialElementHandlers = {
'#editor': function (element, renderer) {
return true;
}
};
$('#cmd').click(function () {
doc.fromHTML($('#content').html(), 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
});
doc.save('sample-file.pdf');
});
});
</script>
我发现了。很简单:)第一个Param用于jsPDF()
中的景观,这就是l
用于景观。
var pdf = new jsPDF('l', 'mm', [297, 210]); //The first Param is for landscape or portrait
app.component.ts
@ViewChild('pdfContent') pdfContent: ElementRef;
async capture() {
// var doc = new jspdf("p", "pt", "a4"); // For Portrait
var doc = new jspdf('l', 'pt', "a4"); // For landscape
//code
})
app.component.html
<div class="col-md-12" class="tablejoin" #pdfContent id =
"entireTable" >
<table> .. </table>
</div>
使用以下代码进行人像模式。
var doc = new jsPDF('l', 'mm', 'a4'); // optional parameters
doc.addImage(img/imgdata, 'PNG', 10, 10, 280, 180);
doc.save("new.pdf");
在为pdf添加图像或数据时配置尺寸。
相关文章:
- 如何使用javascript或html下载PDF格式的填写表单
- 在提交时打开thankyou.html+下载PDF
- 生成pdf或其他非html文件时的错误处理
- how to convert html <div> to pdf
- 如何在使用jsPDF将html转换为pdf的同时,在pdf中的某个点进行分页
- 如何将带有大量svg图表的html转换为pdf
- 将php页面的一个部分渲染为HTML和CSS后生成PDF,并考虑PDF分页符
- 如何使用javascript或jquery将整个html页面转换为pdf
- 如果iframe在src(pdf或text)中有非html文档,则iframe中的onload不起作用
- HTML表格导出为具有适当列宽和字体的pdf
- 具有可拖动元素的HTML到PDF
- c# mvc nreco HtmlToPdfConverter 问题将 html 文档转换为 pdf
- 来自HTML图像的jsPDF 会导致 pdf 为空
- 使用 php 将 pdf 文件转换为 html 文件
- HTML到PDF的转换仅在客户端使用JavaScript
- 从横向格式的HTML页面制作PDF
- 使用TableExport.js将HTML表格导出为PDF、WORD、PNG
- HTML和CSS转换为JavaScript中的PDF
- JQuery-HTML到PDF没有'无法在IE中工作(来自C#asmx Web服务)
- 保存样式'导出到pdf'html表