Search code examples
angularjspdfmake

Remove header from pdfmake table.


I am using the pdfmake to create the pdf. I used following code to create the dynamic table.

buildTableBody(data, columns) {
    var body = [];

    body.push(columns);

    data.forEach(function (row) {
      var dataRow = [];

      columns.forEach(function (column) {
        dataRow.push(row[column].toString());
      })

      body.push(dataRow);
    });

    return body;
  }

  table(data, columns) {
    return {
      table: {
        style: 'tableExample',
        margin: [0,-1,-1,-1],
        widths: ['50%','50%'],
        //headerRows: 1,
        body: this.buildTableBody(data, columns)
      }
    };
  }

and the content table is: this.table(this.externalDataRetrievedFromServer, ['name', 'value']),

Output:

enter image description here

In above table header is showing with column name "name" and "value". I want to remove this header and just show the rows below the header. I tried with removing header name from table definition in content but not working. Thanks in advance.


Solution

  • You need remove

     body.push(columns);
    

    in buildTableBody function to make this hidden