0

I am using html2pdf to download a PDF of my website. The downloaded PDF is 14 pages long. After about 12 pages I can see that the elements that had colors are no longer there. If I try to download the PDF on a mobile screen this starts even sooner at around 6 or 7th page. There are no colors anymore and some of the input elements are missing.

Is there a way for html2pdf to handle larger content?

This is my setting right now

var element = document.getElementById('element-to-print');
var opt = {
  margin:       0,
  filename:     'myfile.pdf',
  image:        { type: 'jpeg', quality: 0.98 },
  html2canvas:  { scale:1 },
  jsPDF:        { unit: 'in', format: 'letter', orientation: 'portrait' }
};
html2pdf(element).set(opt)

I tried increasing the quality to 2 from 0.98 but nothing changes.

Hyyan Abo Fakher
  • 3,497
  • 3
  • 21
  • 35
greenn
  • 309
  • 1
  • 6
  • 18

2 Answers2

0

You can use web workers to download the file in the background without impacting user experience. See this StackOverflow answer for a detailed example.

theterminalguy
  • 1,842
  • 18
  • 20
0

Try reducing the scale in the html2canvas option. Helped me get the colors on all pages.

Tadas Majeris
  • 361
  • 2
  • 4
  • 12