I am trying to create rows with image and description if the element have. When I insert the image, the cell does not fit the image to fit, I am using the didParseCell hook but this causes me problems when doing page breaks or maybe I'm doing something wrong.
I'm using 1.5.3 version of jsPDF and 3.2.4 version of autoTable-jsPDF.
Code example:
When drawing something with the didParseCell hook you need to check that it fits the page and cell yourself and if not add a new page or increase the cell dimensions.
If you want image to fit correctly and page-break work automatically, you need to manually set cell width & height according to image dimensions.
You can do that in the definition of each image cell using cellWidth & minCellHeight properties under styles, or you could set it later using didParseCell hook by updating data.cell.styles.cellWidth & data.cell.styles.minCellHeight.
But you shouldn't update other dimensions in didParseCell hook like row.height because that gets calculated based on cell later after didParseCell.
Also note you could use padding instead of cellWidth & minCellHeight if your cell has text content and you want to add an image next to that.
@mmghv Thanks you for help.
I change row.height inside of didParseCell to data.cell.styles.cellWidth & data.cell.styles.minCellHeight and I set pageBreak: 'auto ' & rowPageBreak: 'avoid'. Now it is working properly.
Most helpful comment
If you want image to fit correctly and page-break work automatically, you need to manually set cell width & height according to image dimensions.
You can do that in the definition of each image cell using
cellWidth&minCellHeightproperties understyles, or you could set it later usingdidParseCellhook by updatingdata.cell.styles.cellWidth&data.cell.styles.minCellHeight.But you shouldn't update other dimensions in
didParseCellhook likerow.heightbecause that gets calculated based on cell later afterdidParseCell.Also note you could use
paddinginstead ofcellWidth&minCellHeightif your cell has text content and you want to add an image next to that.