Set table width to 100% on PDF export in Datatables

I've been using DataTables a lot these days, it's good. Actually, it's a very good plug-in for displaying data in table (haha), with lots of interaction.

Few and should be implemented feature:

  • Can't export multiple table headers
  • API for table width in PDF Export 
  • Adding header and footer for Excel Export
DataTables uses pdfmake library for its pdf export module.

Sample output of pdf

To make the table width 100%, as per pdfmake documentation we should set its width to "*".

Here it goes:

Edit the datatables JS file, find t.table.widths="auto", change it to t.table.widths="*".

You might want to change the alignment of the table header also:


Set the alignment to left.
sample output after the tweak

Popular posts from this blog

Add/Subtract Single Digit Number in Assembly Language

Hot/Cute flat-chested Girls