Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

345
Views
¿Cómo evitar que html2canvas tome capturas de pantalla después de mostrar mi pdf?

Estoy usando jspdf autotable y html2canvas en React.js para crear y mostrar un pdf en mi página. Todo funciona bien, pero después de que se muestra Mi pdf en la ventana emergente, se agrega una captura de pantalla adicional a continuación en mi página. Quiero evitar esta captura de pantalla.

Cuando miras la primera imagen, todo funciona bien y puedo ver mi pdf en la ventana emergente. Pero cuando cierro esa ventana emergente, se crea una captura de pantalla a continuación. Puedes verlo en la segunda imagen. Hay alguna manera de prevenirlo? Foto 1 Foto2

Aquí está mi código:

 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 answers
Answer question

0

He resuelto mi problema. El problema es que html2canvas se crea como una captura de pantalla en index.html cada vez que lo llamo. Por lo tanto me puse

 <style> canvas{ display: none !important; } </style>

en index.html. ¡Entonces funciona!

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!