1

I am trying convert the html div element to pdf file using jspdf. i have included all js script including form_html.js. still i am getting "TypeError: doc.fromHTML is not a function".

<script type="text/javascript" src="jsPDF-master/jspdf.js"></script>
<script type="text/javascript" src="jsPDF-master/jspdf.plugin.addimage.js"></script>
<script type="text/javascript" src="jsPDF-master/jspdf.plugin.cell.js"></script>
<script type="text/javascript" src="jsPDF-master/jspdf.plugin.ie_below_9_shim.js"></script>
<script type="text/javascript" src="jsPDF-master/jspdf.plugin.javascript.js"></script>
<script type="text/javascript" src="jsPDF-master/jspdf.plugin.from_html.js"></script>
<script type="text/javascript" src="jsPDF-master/libs/FileSaver.js/FileSaver.js"></script>
<script type="text/javascript" src="jsPDF-master/jspdf.plugin.sillysvgrenderer.js"></script>
<script type="text/javascript" src="jsPDF-master/jspdf.plugin.split_text_to_size.js"></script>
<script type="text/javascript" src="jsPDF-master/jspdf.plugin.standard_fonts_metrics.js"></script>
<script type="text/javascript" src="jsPDF-master/jspdf.PLUGINTEMPLATE.js"></script>
<script src="jspdf.debug.js"></script>
<script src="jspdf.plugin.from_html.js"></script>

and javascript is

jQuery(function($) {
    $("#button1").click(function(){
        var doc = new jsPDF();
        var specialElementHandlers = {
            '#simple': function (element, renderer) {
                return true;
            }
        };           

       var source = $('#simple').html();
       doc.fromHTML(source, 0.5, 0.5, {
            'width': 75,'elementHandlers': specialElementHandlers
        });
        doc.output("dataurlnewwindow");
});
});

Pls help me in fixing this

Dadu
  • 89
  • 3
  • 14

1 Answers1

0

i might be wrong because i have not run your code but i notice is you have not included a jquery library into the script tag and you are using a jquery function. Try including Jquery and retry hope that solves your problem..