本文介绍了如何使用html2pdf在分页符后添加填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用html2pdf将vue.js html转换为pdf.在这里一切都很好,我只需要在分页符元素之后添加padding-top和padding-bottom.
Converting vue.js html to pdf using html2pdf. Here everything is fine, Only thing i need to add padding-top and padding-bottom after pagebreak elements.
这是我尝试过的代码.
var element = document.getElementById('inner');
var opt = {
margin: 0,
filename: this.auth_user,
image: {type: 'jpeg',quality: 0.98},
html2canvas: {
scale: 2,
bottom: 20
},
pagebreak: { mode: ['css']},
jsPDF: {
unit: 'mm',
orientation: 'portrait'
}
};
html2pdf().set(opt).from(element).then(function() {
$("#inner").css( { "font-size":"12px", "background-color" : "#F5F5F5" });
}).save();
这里需要填充
以下是示例
这将挽救我的生活
推荐答案
唯一的填写方法是通过CSS,但是您可以像这样为文档定义边距:
The only way to fill it out is through CSS, but you can define a margin for your document like this:
var opt = {
margin: [30, 0, 30, 0], //top, left, buttom, right
filename: this.auth_user,
image: {type: 'jpeg',quality: 0.98},
html2canvas: {
scale: 2,
bottom: 20
},
pagebreak: { mode: ['css']},
jsPDF: {
unit: 'mm',
orientation: 'portrait'
}
};
这篇关于如何使用html2pdf在分页符后添加填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!