jsPDF and jsPDF auto table - height issue

2019-08-19 06:04发布

问题:

I have the below code to retrieve the array list of elements to a pdf doc. I am using A4 size. Since the number of columns are more , I am getting all the data in an ellipsis format. Is there anyway I can download the doc as a landscape view instead of portrait view, so that I can avoid the ellipsis and I can see all the datas properly ? As an alternate option I tried to use A1 size, it looks fine as a PDF , but the problem comes when i take a print out of the document as a A4 sheet. The font size is very small after taking the print out. So I want to achieve all the datas to be visible properly without any ellipsis in landscape view with A1. ( This way I will not have any issues in viewing the pdf and also when I take pritnout of the same )

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');
}

回答1:

Use

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

or

 var doc = new jsPDF('landscape');

instead of

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

and then pls chk