I'm using jspdf autotable and html2canvas in React.js to create and show a pdf on my page. Everything works well but after My pdf is showen on teh pop-Up then an extra screenshot is added at below on my page. I want to prevent this screenshot.
When you look at the first picture , everything works well and I can see my pdf on the pop-up. But When I close that pop-up then a screenshot is created at below. You can see it at second picture. Is there any way to prevent it?

Here is my code:
doc.autoTable({
showHead:'firstPage',
margin:5,
startY: 60,
body: bodyData,
columns: [
{ header: 'Sıra', dataKey: 'Count' },
{ header: 'Gelir Tipi', dataKey: 'AccrumentTypeName' },
{ header: 'Gelir Türü', dataKey: 'RevenueName' },
{ header: 'Tahakkuk Tutarı', dataKey: 'TotalAmount' },
],
styles: {
font: 'NotoSans-Regular',
lineWidth: 0.2,
lineColor: 0,
fontSize:7,
},
didParseCell: function (data) {
var rows = data.table.body;
if (data.row.index === rows.length - 1) {
data.cell.styles.fillColor = [176, 224, 230];
}
}
})
const pageCount = doc.internal.getNumberOfPages();
doc.setFontSize(8)
for (var i = 1; i <= pageCount; i++) {
doc.setPage(i)
doc.text('Sayfa ' + String(i) + ' / ' + String(pageCount), doc.internal.pageSize.width / 2, 294, {
align: 'center'
})
}
//Create screenshot of body
html2canvas(document.body, {scale: 2,scrollY: 0,height: window.outerHeight + window.innerHeight, windowHeight: window.outerHeight + window.innerHeight, }).then(canvas => {
document.body.appendChild(canvas);
let output = doc.output('bloburl');
document.getElementById("pdfObj").height = canvas.height / 4;
document.getElementById("pdfObj").data = output;
});
I've solved my problem. The problem is that html2canvas is creating as a screenshot in index.html every time I call it. Therefore I set
<style>
canvas{
display: none !important;
}
</style>
in index.html. Then it works!