Use hooks to customize table rendering
mainHooks allow you to intercept the rendering process to modify content or draw custom elements (like images) during specific lifecycle stages of the table generation.
// Example: Drawing an image in the first column of every body row
autoTable(doc, {
didDrawCell: (data) => {
if (data.section === 'body' && data.column.index === 0) {
const base64Img = 'data:image/jpeg;base64,iVBORw0KGgoAAAANS...'
doc.addImage(base64Img, 'JPEG', data.cell.x + 2, data.cell.y + 2, 10, 10)
}
},
})