Jspdf-autotable: Cannot use promises in didDrawCell

Created on 13 Nov 2019  路  2Comments  路  Source: simonbengtsson/jsPDF-AutoTable

Hello,
I want to insert images created on the fly using html2canvas in didDrawCell hook, but not work.
Insert any image outside the promise works fine.
Can you help me?
Thanks in advance

didDrawCell: data => {
if (data.section === 'body' && data.column.index === 0 && index === 0) {
var componente = data.cell.raw.children[0];
var opciones = {logging:false};
html2canvas(componente,opciones)
.then(function (miniImagen) {
imgData = miniImagen.toDataURL('image/png');
this.addImage(imgData, 'png', data.cell.x + 2, data.cell.y + 2, 12, 9);
})
}

question

Most helpful comment

autoTable hooks are synchronous, You should load all your images before calling doc.autoTable().

All 2 comments

autoTable hooks are synchronous, You should load all your images before calling doc.autoTable().

Thanks @mmghv

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mmghv picture mmghv  路  4Comments

ayman-aljullaq picture ayman-aljullaq  路  5Comments

sirishasd picture sirishasd  路  4Comments

bsparacino picture bsparacino  路  3Comments

AminBangash picture AminBangash  路  5Comments