0

I am trying to generate PDF file from HTML table using JSPDF and AutoTable. A html table is given below:

<table id="table" style="display:none;"> <thead> <tr> <th>sl</th> <th>First</th> <th>Last</th> <th>Email</th> <th>Country</th> </tr> <tr> <th>No</th> <th>name</th> <th>name</th> <th>id</th> <th>name</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>xyz</td> <td>jkl</td> <td>abc</td> <td>pqr</td> </tr> </tbody> </table> 

My question: Is there any option to hide the header column named "Sl" when converting the table data into the PDF file?

Fiddle is here : https://jsfiddle.net/tbz8p79j/7/

1 Answer 1

1

Hiding the first column can be accomplished by simply setting it's width to zero:

doc.autoTable(res.columns, res.data, { columnStyles: {0: {columnWidth: 0}} }); 

You can also play with for example the drawCell hook similar to the colspan and rowspan example in the repo.

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

2 Comments

what to do if I want to hide more than one column.. can you please provide me an example
columnStyles: {0: {columnWidth: 0}, 1: {columnWidth: 0}}