I am trying to make an application, which contains html tables.
I want a download button, and onClick event, downloads a PDF file containing all the html tables in it.
Can it be done?
Can someone help me with a function that converts the html table into an object so that it can be pushed into a PDF file through pdfmake?
Looking at the PDFMake getting started page, you have to format your table like this:
So you would take your table and get eh widths of each column and then cycle through the rows to create the body array:
I found a working solution over here: https://github.com/bpampuch/pdfmake/issues/205
You can get the HTML code of any HTML element(I am demonstrating table) using the following code & call the ParseHTML function:
The full working solution from here. Try yourself running here the example. If you have a main container
div
with aid="test"
, with this set of functions you just need to callpdfForElement('test').download();