为什么下面的 jspdf 代码在下一页打印数据?
why is the jspdf code below printing the data on next page?
下面的代码是 java 脚本的一个片段,它使用 jspdf 生成 html file.i 的 pdf,我正在使用 HTML 渲染器从 a.jsp id 为#formcare 的文件。
function formpdf(){
var doc = new jsPDF();
var imgData = 'data:image/png;base64,iVBORwuy9B5xcZ3kvrHCTmy'; //image url
doc.addImage(imgData, 'PNG', 90, 05, 25,25);
doc.setFont("times");
doc.setFontType("normal");
doc.setFontSize("14");
doc.text(90,35, 'IDeaS INDIA');
doc.text(50,40,'Reimbursement Form For Employee Day Care');
doc.setFontSize("12");
doc.text(70,55,document.getElementById("date").value);
doc.text(70,60,document.getElementById("name").value);
doc.text(70,65,document.getElementById("department").value);
doc.text(70,70,document.getElementById("designation").value);
doc.text(70,75,document.getElementById("daycare").value);
doc.text(70,80,document.getElementById("childName").value);
doc.text(70,85,document.getElementById("dob").value);
doc.text(70,90,document.getElementById("age").value);
var specialElementHandlers = {
'#editor': function(element, renderer){
return true;
}
};
//formcare is my tableId in .jsp file
doc.fromHTML($('#formcare').get(0), 15, 50, {
'width': 170,
'elementHandlers': specialElementHandlers
});
doc.text(10,190,'Note-Employees to ensure that the DAY CARE Center is registered under shop act establishment.');
doc.text(10,200,'Employees will be responsible towards the safety of the child and company holds no obligation.');
doc.save('form.pdf');
}
根据 https://parall.ax/products/jspdf HTML 渲染仍处于早期阶段。
它不支持 css 和样式。
因此,如果您想要单页文档,请检查您正在呈现的 html/div。尝试减少 <br>
或 html/div
中的其他换行标记
如果您使用 bootstrap 样式,此问题将得到解决!
下面的代码是 java 脚本的一个片段,它使用 jspdf 生成 html file.i 的 pdf,我正在使用 HTML 渲染器从 a.jsp id 为#formcare 的文件。
function formpdf(){
var doc = new jsPDF();
var imgData = 'data:image/png;base64,iVBORwuy9B5xcZ3kvrHCTmy'; //image url
doc.addImage(imgData, 'PNG', 90, 05, 25,25);
doc.setFont("times");
doc.setFontType("normal");
doc.setFontSize("14");
doc.text(90,35, 'IDeaS INDIA');
doc.text(50,40,'Reimbursement Form For Employee Day Care');
doc.setFontSize("12");
doc.text(70,55,document.getElementById("date").value);
doc.text(70,60,document.getElementById("name").value);
doc.text(70,65,document.getElementById("department").value);
doc.text(70,70,document.getElementById("designation").value);
doc.text(70,75,document.getElementById("daycare").value);
doc.text(70,80,document.getElementById("childName").value);
doc.text(70,85,document.getElementById("dob").value);
doc.text(70,90,document.getElementById("age").value);
var specialElementHandlers = {
'#editor': function(element, renderer){
return true;
}
};
//formcare is my tableId in .jsp file
doc.fromHTML($('#formcare').get(0), 15, 50, {
'width': 170,
'elementHandlers': specialElementHandlers
});
doc.text(10,190,'Note-Employees to ensure that the DAY CARE Center is registered under shop act establishment.');
doc.text(10,200,'Employees will be responsible towards the safety of the child and company holds no obligation.');
doc.save('form.pdf');
}
根据 https://parall.ax/products/jspdf HTML 渲染仍处于早期阶段。 它不支持 css 和样式。
因此,如果您想要单页文档,请检查您正在呈现的 html/div。尝试减少 <br>
或 html/div
如果您使用 bootstrap 样式,此问题将得到解决!