0

I have been trying to set the column width for a PDF export in Tabulator. Using http://tabulator.info/docs/4.5/download#pdf and https://github.com/simonbengtsson/jsPDF-AutoTable#styling-options as references, I wrote this code:

table.download("pdf", "data.pdf", {
    "orientation":"portrait",

    "autoTable":{
        "columnStyles": {
            "allocated_site_name": {"cellWidth": 20}
        },
        margin: {
            "top": 40,
            "right": 20,
            "bottom": 20,
            "left": 20
        }
    }
});

However, it seems as though columnStyles is ignored, although margin works.

Am I doing anything wrong?

I am using:

  • Tabulator 4.5
  • jspdf 1.3.5
  • jspdf-autotable 3.0.5

Thank you!

  • 1
    Have a look at this post about [Setting column widths on autotable](https://stackoverflow.com/questions/38787437/different-width-for-each-columns-in-jspdf-autotable) – Oli Folkerd Aug 09 '20 at 11:13
  • Thanks @OliFolkerd. Sorry for the delayed response. The only difference I see between the accepted answer there and my code is that they use indexes rather than the column names to specify the applicable column. Using indexes also did not change the cell width for me. Is there something I am missing? – Richard Slabbert Aug 18 '20 at 08:05
  • @OliFolkerd - I see now that it does need to be the index. Thanks for the tip. In my case, though, the cell width was not going smaller than about 40 and that is why I did not realize that you were right. I guess this is then an autotable issue. Thanks again for the awesome library! – Richard Slabbert Aug 18 '20 at 08:46
  • @OliFolkerd - Perhaps you should change the example in the documentation for PDF download so you don't get any other support queries like this one? (For anyone interested, the cell wasn't going smaller because it cannot go smaller than the column header - which was about 40 pixels) – Richard Slabbert Aug 18 '20 at 09:28

0 Answers0