0

I want to generate a table from node.js to be printed in pdf format using html-pdf library but unfortunately my code won't work. The problem is because the html-pdf won't execute html tags. It execute the tags as string instead.

var tableBody = '';
for (i = 1; i < data.lenght; i++);
{
     tableBody = tableBody + '<tr>' +
                '<td>' + data[i].full_name + '</td>' +
                '<td>' + data[i].age + '</td>' +
                '<td>' + data[i].address + '</td>' +
             '</tr>';
 }
pdfParam.tableBody = tableBody;

then in html file, my code just like this.

<table>
  <tbody>
      {{tableBody}}
  </tbody>
</table>

Is there a way to solve this? Any answers and comments are really appreciated.

dede
  • 653
  • 3
  • 10
  • 23

1 Answers1

1

I used your code and it served me very well, I only made a couple of changes:

var tableBody = '';
for (i = 1; i < data.lenght; i++)(drop this semicolon)
{
     tableBody = tableBody + '<tr>' +
                '<td>' + data[i].full_name + '</td>' +
                '<td>' + data[i].age + '</td>' +
                '<td>' + data[i].address + '</td>' +
             '</tr>';
 }
(drop this param)

in the var content (html):

only ${tableBody} in the right place...