Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将json字典作为表写入pdf_Json_Html_Pdf_Jspdf - Fatal编程技术网

将json字典作为表写入pdf

将json字典作为表写入pdf,json,html,pdf,jspdf,Json,Html,Pdf,Jspdf,我有一本包含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,如下所示: 目前

我有一本包含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');
let doc:any=new jsPDF();
文件设置线宽(1000);
让items=this.getItems();
让pageHeight=doc.internal.pageSize.height;
//在添加新内容之前
设y=0;//新内容的高度位置
for(设i=0;i=页面高度-10){
doc.addPage();
y=-1;//重新启动高度位置
}
y+=10;
}
doc.save('myTest.pdf');