Skip to content Skip to sidebar Skip to footer

Html2canvas/jspdf Only Converts The Data In The Viewport To Pdf?

I am trying to use the html2Canvas to convert html content to pdf. I have one consent form which is long and we have to scroll like below. I have written below code to convert th

Solution 1:

  loadPDF() {
let doc = new jsPDF('p', 'pt', 'a4');
h2c(document.getElementById('mybarchart')).then(function (canvas) {
  let width = doc.internal.pageSize.getWidth();
  let height = doc.internal.pageSize.getHeight();
  let dataURL = canvas.toDataURL('image/jpeg', 1.0);
  doc.addImage(dataURL, 'jpg', 0, 0, width, height, 'none');
  doc.save(`test.pdf`);
  document.getElementById("pdfLoader").classList.remove('loader');
  setTimeout(() => {
    window.close();
    }, 2000);
  });
}

Post a Comment for "Html2canvas/jspdf Only Converts The Data In The Viewport To Pdf?"