How to add a different div in the samefile with jspdf

By Alex Maya

I want to convert the other div with id=”page2″ in my html to an image and add it on another page in the same pdf file
this is my code:

   <script type="text/javascript" src="jspdf.min.js"></script>
   <script type="text/javascript" src="html2canvas.js"></script>
   <script type="text/javascript">
     function genPDF() {
       html2canvas(document.getElementById('hoja1'),{
         onrendered: function (canvas) {
         var img = canvas.toDataURL("image/png");
         var doc= new jsPDF();
         doc.addImage(img,'JPEG',0,0,210,230);
         doc.save('ContratoMutuo.pdf');
        }
       });
     }
   </script>

but only work with one div

and the html code is:

        <!DOCTYPE html>
        <html>
          <head>
            <meta charset="utf-8">
            <title>file</title>
            <script type="text/javascript" src="jspdf.min.js"></script>
            <script type="text/javascript" src="html2canvas.js"></script>
            <script type="text/javascript">
              function genPDF() {
                html2canvas(document.getElementById('hoja1'),{
                  onrendered: function (canvas) {
                  var img = canvas.toDataURL("image/png");
                  var doc= new jsPDF();
                  doc.addImage(img,'JPEG',0,0,50,50);
                  doc.save('test.pdf');
                 }
                });
              }
            </script>
          </head>
          <body>
            <div id="hoja1">
                <TABLE WIDTH=300 HEIGHT=200>
                  <TD width=100 BGCOLOR="red">prueba </TD>
                  <TD WIDTH=100 BGCOLOR="yellow">prueba </TD>
                  <TD WIDTH=100 BGCOLOR="gray">prueba </TD>
                </TABLE>
            </div>
            <div id="hoja2">
              <TABLE WIDTH=300 HEIGHT=200>
                <TD width=100 BGCOLOR="green">prueba </TD>
                <TD WIDTH=100 BGCOLOR="blue">prueba </TD>
                <TD WIDTH=100 BGCOLOR="gray">prueba </TD>
              </TABLE>
            </div>
            <a href="javascript: genPDF()">DOWNLOAD PDF</a>
          </body>
        </html>

the complete file should be:

1/2

and
2/2

in the same file please help!! thankyou!

Source: Stack Overflow

    

Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273