我有一个包含2000多个项目的对象字典,例如:
{
{"ID":1, "Name":"one", "IsKey":true},
{"ID":2, "Name":"two", "IsKey":false},
{"ID":3, "Name":"three", "IsKey":false},
......
{"ID":2500, "Name":"million", "IsKey":true},
}
我想创建一个多页PDF,如下所示:
目前我正在使用jsPDF执行此操作,但页面看起来并不像我想要的那样。
let doc: any = new jsPDF();
doc.setLineWidth(1000);
let items = this.getItems();
let pageHeight = doc.internal.pageSize.height;
// Before adding new content
let y = 0; // Height position of new content
for (let i = 0; i < items.length; i++) {
doc.text(0, y, JSON.stringify(items[i]));
if (y >= pageHeight - 10) {
doc.addPage();
y = -1; // Restart height position
}
y += 10;
}
doc.save('myTest.pdf');