JsPdf using html2canvas.js: Unpatched error: supplied data is not JPEG

I use jsPDF and html2Canvas to create a PDF.

It works if I am targeting document.body.

<script type="text/javascript">
  function pdfDownload() {
  var pdf = new jsPDF('p', 'pt', 'a4');
  pdf.addHTML(document.body, function () {
  pdf.save('test.pdf');
  });
}</script>

However, if I try to use id in the #pdfcontent div, I get:

"Unused error: the supplied data is not JPEG"

<script type="text/javascript">
  function pdfDownload() {
  var pdf = new jsPDF('p', 'pt', 'a4');
  pdf.addHTML($('#pdfcontent')[0], function () {
  pdf.save('test.pdf');
  });
}</script>

help me please

+4
source share
1 answer

I had the same problem, nowadays jsPDF is updated and does not work with html2canvas.

( ), html2canvas ( jsPDF-AutoTable) jsPDF-AutoTable)

+1

All Articles