eKoopmans / html2pdf.js

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

Large margin top even if already set margin to 1 #499

Open lstrdgr8 opened 2 years ago

lstrdgr8 commented 2 years ago

Hello,

Good day.

I am currently facing issue when printing the my list of QRS using html2pdf. Below are my code snippet.

function printContentToPDF(rowCount, count, z) { var source = document.getElementById('qrWrapperMain').innerHTML; var fileName = 'NurserySeedlings - ' + getFormattedTime() + '.pdf'; var opt = { filename: fileName, margin: [1, 20, 50, 0] image: { type: 'png', quality: 0.98 }, html2canvas: { scale: 2, dpi: 192 }, pagebreak: { mode: ['legacy', 'css'] }, jsPDF: { unit: 'pt', format: 'a4', orientation: 'portrait' } }; html2pdf().from(source).set(opt).toPdf().save(); }

however, when it was printed in the PDF, the top margin is so big that almost the PDF doesn't have data. I am attaching here the generated PDF as well as the inner HTML content for perusal. Thank you so much.

Content.zip

Violella commented 2 years ago

I had the same issue. My problem was that I had to scroll down to reach my html2pdf-button. When the button was on top of the page there was no problem.

I solved it with this: https://github.com/eKoopmans/html2pdf.js/issues/420

Does this fix your problem too?