javascript - A HTML to PDF converter button using jspdf -
the pdf generator button in html webpage not working. can please explain going wrong?
i using jquery version 1.7.2.
<!doctype html> <html> <head> <title>print fax view</title> <meta content="text/html; charset=utf-8" http-equiv=content-type> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script type="text/javascript" src="js/jquery"></script> <script type="text/javascript" src="jspdf/jspdf.js"></script> <script type="text/javascript" src="jspdf/jspdf.plugin.standard_fonts_metrics.js"></script> <script type="text/javascript" src="jspdf/jspdf.plugin.split_text_to_size.js"></script> <script type="text/javascript" src="jspdf/jspdf.plugin.from_html.js"></script> <script type="text/javascript" src="jspdf/libs/deflate/adler32cs.js"></script> <script type="text/javascript" src="jspdf/libs/filesaver.js/filesaver.js"></script> <script type="text/javascript" src="jspdf/libs/blob.js/blobbuilder.js"></script> <script type="text/javascript" src="jspdf/jspdf.plugin.addimage.js"></script> <script type="text/javascript" src="js/basic.js"></script> <script type="text/javascript"> $(document).ready(function(){ var specialelementhandlers = { '#editor': function (element,renderer) { return true; } }; $('#cmd').click(function () { var doc = new jspdf("p",in,"a4"); var source = $('#target').html(); var specialelementhandlers = { '#bypassme': function (element, renderer) { return true; } }; doc.fromhtml(source, 0.5, 0.5, { 'width': 7.5,'elementhandlers': specialelementhandlers }); doc.output("dataurlnewwindow"); }); }); </script> </head> <body id="target"> <button id="cmd">generate pdf</button> <div> <p>hello world </p> </div> </body> </html>
it not generating anything. in advance
i beginner html, javascript. here corrected, generating pdf.
<!doctype html> <html> <head> <title>print fax view</title> <meta content="text/html; charset=utf-8" http-equiv=content-type> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script type="text/javascript" src="jspdf/jspdf.js"></script> <script type="text/javascript" src="jspdf/jspdf.plugin.addimage.js"></script> <script type="text/javascript" src="jspdf/jspdf.plugin.cell.js"></script> <script type="text/javascript" src="jspdf/jspdf.plugin.from_html.js"></script> <script type="text/javascript" src="jspdf/jspdf.plugin.ie_below_9_shim.js"></script> <script type="text/javascript" src="jspdf/jspdf.plugin.javascript.js"></script> <script type="text/javascript" src="jspdf/jspdf.plugin.sillysvgrenderer.js"></script> <script type="text/javascript" src="jspdf/jspdf.plugin.split_text_to_size.js"></script> <script type="text/javascript" src="jspdf/jspdf.plugin.standard_fonts_metrics.js"></script> <script type="text/javascript" src="jspdf/jspdf.plugintemplate.js"></script> <script type="text/javascript" src="lib/jquery-1.11.0.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ var specialelementhandlers = { '#editor': function (element,renderer) { return true; } }; $('#cmd').click(function () { var doc = new jspdf(); var source = $('#target').html(); var specialelementhandlers = { '#bypassme': function (element, renderer) { return true; } }; doc.fromhtml(source, 0.5, 0.5, { 'width': 75,'elementhandlers': specialelementhandlers }); doc.output("dataurlnewwindow"); }); }); </script> </head> <body id="target"> <button id="cmd">generate pdf</button> <div> <p>hello world </p> </div> </body> </html>
Comments
Post a Comment