jsPDF和jsPDF自动表 - 高度问题

时间:2018-05-23 08:56:20

标签: jspdf jspdf-autotable

我有以下代码来检索pdf doc的元素数组列表。 我正在使用A4尺寸。由于列数更多,我得到的是省略号格式的所有数据。 无论如何我可以下载文档作为横向视图而不是纵向视图,这样我就可以避免省略号,我可以正确地看到所有数据? 作为替代选项,我试图使用A1尺寸,它看起来很好,因为PDF,但问题是当我从A4文件打印出来的文件。打印后字体大小非常小。所以我希望在A1的横向视图中实现所有数据的正确显示,而不需要任何省略号。 (这样我在查看pdf时也不会有任何问题,而且当我采取同样的方式时也不会有任何问题)

convert() {

  const doc = new jsPDF('p', 'pt', 'A4');
   const col = ['Discharge Date', 'Case Number', 'Patient', 'Hospital', 'Payee', 'Total Doctor Fee', 'To be Collected', 'Payor', 'Remarks', 'Paid', 'Unpaid'];

  const rows = [];


/* The following array of object as response from the API req  */

const itemNew = this.finalArList;

itemNew.forEach(element => {

  const temp = [element.dischargeDate, element.caseNo, element.patientName, element.instName, element.clinicName, element.formattedTotalDrFee, element.formattedUnpaidAmounr, element.payor, element.remark, element.formattedTotalDrFee, element.formattedUnpaidAmounr];
  rows.push(temp);
  doc.autoTable(col, rows,  {margin: {top: 10}, height: 'auto' });

 });
doc.save('MyReport.pdf');
}

enter image description here

1 个答案:

答案 0 :(得分:1)

使用

new jsPDF('l', 'mm', 'a4');

 var doc = new jsPDF('landscape');

而不是

new jsPDF('p', 'pt', 'A4');

然后pls chk

相关问题