Found an easier and quicker way to do it.
{
extend: 'pdf',
customize: function (doc) {
doc.content[1].table.widths =
Array(doc.content[1].table.body[0].length + 1).join('*').split('');
}
}
What happens here is as so:
doc.content[1].table.widths
is an array of widths for each column, and if each of them is a '*'
it means that the table will fit 100% of the page with the columns distributed evenly.
Array(doc.content[1].table.body[0].length + 1)
creates an array in the length of all the columns of my table.
.join('*')
creates a string from all the cells in the array with a '*'
for each.
.split('');
splits it back into an array.
Hope I helped someone along the way.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…