Search code examples
jspdfjspdf-autotable

jsPDF-AutoTable: Image does not match the row to change pages


I appreciate the help for the following with jsPDF AutoTable v2.3.0.

I have a table with images in the first column with the following style:

styles: {overflow: 'linebreak', columnWidth: 'wrap'},
    columnStyles: {
        0: {columnWidth: 25},
        1: {columnWidth: 350}
},

When the table occupies two pages, the images do not fit correctly in the row.

Example: https://jsfiddle.net/shinseiki86/60qrh6e1/

Result: https://i.sstatic.net/PykQw.png

Thanks!


Solution

  • Fixed using the issue reported in the following link:

      drawCell: function(cell, opts) {
        if (opts.column.dataKey === 0 && opts.row.index < data.rows.length) {
          images.push({
            elem: imgElements[opts.row.index],
            x: cell.textPos.x,
            y: cell.textPos.y
          });
        }
      },
    

    Solution: https://jsfiddle.net/shinseiki86/j5dz8dv8/