Converting Canvas to Pdf using JsPDF
38,171
Try this instead:
var pdf = new jsPDF('p','pt','a4');
pdf.addHTML(document.body,function() {
pdf.output('datauri');
});
See http://mrrio.github.io/jsPDF/
Author by
Addy
Android App Developer by choice and Web Developer by force, love PC games, love football and cricket.
Updated on July 17, 2022Comments
-
Addy almost 2 years
I am trying to convert canvas into pdf but i get clean white pdf in result Here is the code, I am not being able to figure out what i am missing..
function HtmlToImage(){ html2canvas(document.body, { onrendered: function(canvas) { var img =canvas.toDataURL("image/jpeg,1.0"); var pdf = new jsPDF(); pdf.addImage(img, 'JPEG', 0, 0); pdf.output('datauri'); } }); }
-
Addy almost 10 yearsit says ..pdf.addHTML(document.body,function()
-
Addy almost 10 yearssorry, means debugger is not recognizing this addHTML function
-
diegocr almost 10 yearsaddHTML is a new jsPDF plugin, pick the latest version from github.com/MrRio/jsPDF/tree/master/dist
-
Mohammad Faizan khan about 9 yearsblurry image found using this sadly