showing results for - "jspdf create table"
Anna
24 May 2020
1convert() {
2
3       var doc = new jsPDF();
4       var col = ["Sr. No.","Details"];
5       var col1 = ["Details", "Values"];
6       var rows = [];
7       var rows1 = [];
8
9  /* The following array of object as response from the API req  */
10
11
12
13var itemNew = [
14
15  { index:'1',id: 'Case Number', name : '101111111' },
16  { index:'2',id: 'Patient Name', name : 'UAT DR' },
17  { index:'3',id: 'Hospital Name', name: 'Dr Abcd' }
18
19]
20
21
22   itemNew.forEach(element => {      
23        var temp = [element.index,element.id];
24        var temp1 = [element.id,element.name];
25        rows.push(temp);
26        rows1.push(temp1);
27
28    });        
29
30        doc.autoTable(col, rows, { startY: 10 });
31
32        doc.autoTable(col1, rows1, { startY: 60 });
33        doc.save('Test.pdf');
34      }