Home:ALL Converter>PDFmake table dynamic data

PDFmake table dynamic data

Ask Time:2019-08-29T05:13:31         Author:Muhammad Ali

Json Formatter

I am using PDFmake to create pdf file, I want to add dynamic data in the table butt the body display empty.

this one works when I print [0] but I have lots of dynamic data

 getData(installation, request) {
          const phases = {
            layout: {
              hLineWidth: function(i, node) {
                return 0.45;
              },
              vLineWidth: function(i, node) {
                return 0.45;
              }
            },
            table: {
              dontBreakRows: true,
              widths: ["30%", "10%", "60%"],
              body: [
                [

                  {
                    text: installation.phases[0].text,
                    style: "cell"
                  },
                  { text: installation.phases[0].status},
                  {
                    text: this.getFeedback(installation.phases[0]),
                    style: "commentCell"
                  }
                ],
              ]
            }
          };
          console.log(phases);
          return phases;
      }

but If I use this one it create table body empty.

  getData(installation, request) {
installation.phase.forEach(value =>{
          const phases = {
            layout: {
              hLineWidth: function(i, node) {
                return 0.45;
              },
              vLineWidth: function(i, node) {
                return 0.45;
              }
            },
            table: {
              dontBreakRows: true,
              widths: ["30%", "10%", "60%"],
              body: [
                [

                  {
                    text: data.text,
                    style: "cell"
                  },
                  { text: data.status},
                  {
                    text: this.getFeedback(data),
                    style: "commentCell"
                  }
                ],
              ]
            }
          };
          console.log(phases);
          return phases;
});
}

What could be wrong here? I have tried but cannot find solution

Author:Muhammad Ali,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/57700106/pdfmake-table-dynamic-data
yy