Exclude Columns in jsPDF AutoTable

2019-07-26 21:04发布

问题:

Has somebody experience excluding the columns in the pdf result from a Table using jsPDF autoTable..Would appriciate a little help.

回答1:

Anyway, after digging deep in the API and in the examples. I found a solution. jsPDF with autoTable is kinda tricky specially for beginners so for those who will bump in to this predicament in the near fututre. Here's how:

var tTB = document.getElementById("myTable");
var atTB = doc.autoTableHtmlToJson(tTB, true);
var cols = atTB.columns;
//here you are going to set which column you will truncate. Moreover, .splice(index number of the column(your start), the number of columns you will exclude)
cols.splice(4,1); 
doc.text("My Test Table", 40, 60);
doc.autoPrint();

cheers!



回答2:

Well you can use http://pdfmake.org/ to generate pdf client side. It is much simpler to write a pdf using this library. They also have playground to copy paste your code and watch live pdf.

Thanks,