eKoopmans / html2pdf.js

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

Multiple Page PDF File Not Generated in Highest Version of Google Chrome (Ver. 77.0) #256

Open Amit1042 opened 4 years ago

Amit1042 commented 4 years ago

Hi @eKoopmans, myfile (3).pdf Firstly, I want to thank you for writing this great file. It saves me a lot of time dealing with the quality of content and layout. Recently, I am trying to generate a multiple page PDF file. using listed below code and library. this work fine on every other browser except Google Chrome Latest version 77.0 . in chrome file generated with all pages but every page has a black color background sample enclosed.

please give me a better solution to fix this issue.

const element = document.getElementById("PrintArea"); var opt = { margin: .2, filename: 'myfile.pdf', image: { type: 'jpeg', quality: 0.98 }, pagebreak: { before: '.beforeClass', after: ['#after1', '#after2'], avoid: 'img' }, html2canvas: { dpi: 600, letterRendering: true, useCORS: true }, jsPDF: { unit: 'in', format: 'letter', orientation: 'landscape' } }; html2pdf().set(opt).from(element).save(filename);

html2pdf.js/0.9.1/html2pdf.bundle.min.js html2canvas.min.js jspdf.min.js jspdf.debug.js es6-promise.auto.min.js es6-promise.min.js

SufyanRamzan commented 4 years ago

Hi @Amit1042 I am working on generating pdf using this library but it's not even generating pages for me. Here is my code:

const element = document.getElementById('reportPdf'); const opt = { margin: 0.1, filename: 'supplies-report.pdf', image: { type: 'jpeg', quality: 1 }, html2canvas: { scale: 2 }, jsPDF: { unit: 'in', format: 'a4', orientation: 'landscape' }, pagebreak: { mode: ['css', 'legacy'] } };

html2pdf().set(opt).from(element).save();
Amit1042 commented 4 years ago

Hi @Amit1042 I am working on generating pdf using this library but it's not even generating pages for me. Here is my code:

const element = document.getElementById('reportPdf'); const opt = { margin: 0.1, filename: 'supplies-report.pdf', image: { type: 'jpeg', quality: 1 }, html2canvas: { scale: 2 }, jsPDF: { unit: 'in', format: 'a4', orientation: 'landscape' }, pagebreak: { mode: ['css', 'legacy'] } };

html2pdf().set(opt).from(element).save();

hi Sufyan Ramzan what issue you are facing..?

SufyanRamzan commented 4 years ago

Hi @Amit1042, Thanks for the reply. I am working on generating pdf for the HTML table and the number of rows could exceed the size of a4 page but the htm2pdf is only generating a single page and it's not generating extra pages to show all the data in the table.

pyummm commented 4 years ago

I noticed exactly same problem when generate multipaged pdf on chrome. First time pdf generates properly, second time all pages are black. 7 pages are ok, but 8 already black

offaxis commented 4 years ago

Hi !

I got same problem on Chrome v77, but not on Firefox v69 : Only first page is generated, not second on 2 pages file.

Any clue ?

Thanks in advance !

ashtonlance commented 4 years ago

I've been able to work around the issue by using html2canvas: { scale: 1 }, in the options block.

pyummm commented 4 years ago

Not helped in case of 22 pages document scale:1 looks like decrease resolution to about 150dpi so if it helps to add more not black pages, then somewhere problem with mem allocation