SHARE
TWEET

Untitled

a guest Jun 17th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const html_source = document.getElementById('contentID');   // Get html
  2.  
  3.  html2canvas(html_source).then(function(canvas) { // Convert to canvas
  4.  
  5.    let imgData = canvas.toDataURL('image/png'); // Generates image that you can store
  6.  
  7.    let pdf = new jsPDF('p', 'mm', 'a4'); //Create PDF, Note that you use the same image to create the PDF
  8.    pdf.addImage(imgData, 'PNG', 10, 10);
  9.    pdf.save('test.pdf');
  10.  })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top