javascript - 关于如何使用一组数据但两行标题导出 PDF 的任何建议?
问题描述
我有一个问题,到目前为止,我一直在使用带有 autotable 的 jspdf 来创建简单的报告,一行标题,一组数据,效果很好。
我正在使用 Angular 8
但是,我现在有一份报告,其中需要此布局:
Name: Steve Age: 38 otherTitle: xxx otherTitle: xxx otherTitle: xxx
--NEWLINE--
otherTitle: xxx otherTitle: xxx otherTitle: xxx otherTitle: xxx
本质上是两行标题,其右侧是数据。
网页布局很简单,效果很好。但是将其导出为pdf我不知道该怎么做,有什么建议吗?
解决方案
好的,所以我对我自己的解决方案并不完全满意,但它现在有点像我想要的,如果其他人需要类似的东西,它不会完全赢得奖品。如果有人有更好的解决方案来使用这样的数据创建 pdf那么请回复;D
*仍然使用jspdf
谢谢大家。
const reportCreationDate = Date.now();
let doc = new jsPDF('landscape') as jsPDFWithPlugin;
doc.setFontSize(7);
printArrayL1.forEach((el, i) => {
doc.text(5, 10 + (i * 10), `Header: ${el[0]}`);
doc.text(40, 10 + (i * 10), `Header: ${el[1]}`);
doc.text(80, 10 + (i * 10), `Header: ${el[2]}`);
doc.text(120, 10 + (i * 10), `Header: ${el[3]}`);
doc.text(140, 10 + (i * 10), `Header: ${el[4]}`);
doc.text(180, 10 + (i * 10), `Header: ${el[5]}`);
doc.text(210, 10 + (i * 10), `Header: ${el[6]}`);
doc.text(230, 10 + (i * 10), `Header: ${el[7]}`);
doc.text(260, 10 + (i * 10), `Header: ${el[8]}`);
});
printArrayL2.forEach((el, i) => {
doc.text(5, 15 + (i * 10), `Header: ${el[0]}`);
doc.text(40, 15 + (i * 10), `Header: ${el[1]}`);
doc.text(80, 15 + (i * 10), `Header: ${el[2]}`);
doc.text(120, 15 + (i * 10), `Header: ${el[3]}`);
doc.text(140, 15 + (i * 10), `Header: ${el[4]}`);
doc.text(180, 15 + (i * 10), `Header: ${el[5]}`);
doc.text(210, 15 + (i * 10), `Header: ${el[6]}`);
doc.text(230, 15 + (i * 10), `Header: ${el[7]}`);
doc.text(260, 15 + (i * 10), `Header: ${el[8]}`);
});
推荐阅读
- sockets - 将 Socket 编程从 Ubuntu 移植到 Windows
- r - 如何在 R 中为 Shiny 应用程序输入变量文件?
- go - 继承语法。有什么区别?
- python - 如何在考虑 DST 的同时将 UTC HH:MM(无日期)转换为基于时区的本地时间?
- javascript - 如何在以下情况下正确使用 async-await?
- vba - vba:在 Excel xlsm 文件中查找类型(例如“字典”)的引用
- dictionary - 如何访问模板字符串中的地图?
- javascript - 具有嵌套关系的 TypeORM findOne
- encryption - bcrypt 如何“知道”给定的哈希是否与给定的密码相关联?
- java - 关闭弹出窗口后在 Selenium 中使用页面上的元素