4

I am using html-pdf for pdf creation on my project. i can generate all the details into the pdf. but the thing is i can not be able to create List of items in array in html(which will be used for pdf conversion).
      Since i cannot use javascript to get the array of items, i am unable to get it. if there is a tweak to use javascript in html template,please post it here. Since the array of items is known, i can use it easily.
Suppose if the array length is 3 . i can use like array[0].name ,array[1].name, array[2].name but here i don't know the length of the array which consists of how many items. Can anyone please help me here to generate the table of items which is generating dynamically.

1 Answer 1

3

You cannot use Javascript in template, but you can use Javascript on it.

The idea is to make a parser which will :

  • read your template
  • replace a keywork (for example : <customTable arrayName="myCustomArray" fields="['name']" />) with a generated HTML array in Node.js.
  • use this template with html-parser.

I write an example of parser in VanillaJS here : https://jsfiddle.net/rbuuzcre/5/

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

2 Comments

Thanks for your help, can you update fiddle with 4 columns in the table. please
If you want to add columns, you just need to add some fields in array.

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.