eKoopmans / html2pdf.js

Client-side HTML-to-PDF rendering using pure JS.
MIT License
4.07k stars 1.38k forks source link

Render only what on the screen but not overall #660

Closed NoroleakIng closed 1 year ago

NoroleakIng commented 1 year ago

When I download to pdf, it's able to get or render what shows on the screen but not all, and everything else after that is blank. Is there any solution to this? html2pdf(document.getElementById('export-to-pdf'), { filename: 'download.pdf', margin: 5, })

NoroleakIng commented 1 year ago

Found the solution by using windowHeight. html2pdf(document.getElementById('export-to-pdf'), { filename: 'download.pdf', margin: 5, html2canvas: { scale: 5, imageTimeout: 15000, logging: true, useCORS: true, allowTaint: true, letterRendering: true, height: window.outerHeight + remainingHeight, windowHeight: window.outerHeight + remainingHeight, }, pageBreak: { mode: ['avoid-all', 'css'] }, })