Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

348
Vistas
How to prevent html2canvas to take screenshots after show my pdf?

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? Picture1 Picutre2

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;
    });
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

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!

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda