Search code examples
jspdfjspdf-autotable

How to create an irregular table using AutoTable


Using jspdf-autotable. How can I create a table with a column that has a vertical offset compared to other columns? Similar to the length column in this example:

Irregular table

The table I have today is built with the code below, but I don't know to do the vertical offset.

doc.autoTable({
  head: [['Name', 'Slack (m)', 'Length (m)']],
  body: rows,
  tableWidth: doc.internal.pageSize.getWidth() * 0.33,
  startY: 161,
  margin: {left: 400},
  styles: {fontSize: 8, lineWidth: 1},
  rowPageBreak: 'avoid',
  didDrawPage: pageNumber
});

Solution

  • I couldn't find any way to do the vertical offset by editing the style in autoTable. Instead of creating a table using autoTable I just had to draw lots of boxes in a for loop that all put together would look like a table.

    enter image description here