Skip to content

Instantly share code, notes, and snippets.

@M-Abdullahi
Created February 16, 2019 05:47
Show Gist options
  • Save M-Abdullahi/51952366f4a1cbe7297287bfdd9faa5e to your computer and use it in GitHub Desktop.
Save M-Abdullahi/51952366f4a1cbe7297287bfdd9faa5e to your computer and use it in GitHub Desktop.
Export html div content as image and save it to a pdf file
html2canvas($("#canvas"), {
onrendered: function(canvas) {
var imgData = canvas.toDataURL(
'image/png');
var doc = new jsPDF('p', 'mm');
doc.addImage(imgData, 'PNG', 10, 10);
doc.save('sample-file.pdf');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment