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.

1 Answer 1

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...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.