title: Generating PDF with jsPDF
body: <p>I'm trying to print a table from my webpage as pdf with jsPDF. I create the table in a new window, and what I was doing before find jsPDF was printing the whole new page with the mapped table, but now I need to download the pdf without show the printing wizard, so I tried the <a href="https://github.com/MrRio/jsPDF" rel="nofollow noreferrer">jsPDF</a> scripts for my purpose, but I'm not being able to print the correct format of my table. I have to say I'm using another js called <a href="https://lindell.me/JsBarcode/" rel="nofollow noreferrer">JsBarcode</a> because I need to generate a barcode in my table and print it in the PDF, and for now I'm not being able to print it correctly.</p>
  
  <p>Here is my JavaScript code:</p>
  
  <pre><code>JsBarcode(".barcode").init(); 
  var doc = new jsPDF(); 
  var specialElementHandlers = {
      "#bypassme": function (element, renderer) {
          return true
      }
  }; 
  var margins = {
      top: 80,
      bottom: 60,
      left: 40,
      width: 522
  }; 
  var source = $("#content")[0];
  doc.fromHTML(
      source.innerHTML,
      margins.left, 
      margins.top, 
      {
          "width": margins.width,
          "elementHandlers": specialElementHandlers
      }, 
      function (dispose) { 
          doc.save("Test.pdf"); 
      }, 
      margins
  ); 
  </code></pre>
  
  <p>Here is the HTML:</p>
  
  <pre><code>&lt;div id="content"&gt;
  &lt;table border="2px" class="table" style="border: 2px dashed #000; border-collapse: collapse;" &gt;
      &lt;tr&gt;
          &lt;td style="border: 0px;"&gt;
              &lt;table class="table" style="font-size:13px;"&gt;
                  &lt;tr style="background-color:#bdbdbd;"&gt;
                      &lt;td&gt;VALUE_0&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td style="border: 0px;"&gt;VALUE_0.1&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td style="border: 0px;"&gt;VALUE_0.2&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td style="border: 0px;"&gt;VALUE_0.3&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td style="border: 0px;"&gt;VALUE_0.4&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
          &lt;/td&gt;
          &lt;td style="border: 0px;"&gt;
              &lt;table class="table" border="2px" solid&gt;
                  &lt;tr style="background-color:#bdbdbd;"&gt;
                      &lt;td&gt;&lt;b&gt;VALUE_1&lt;/b&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td style="border: 0px;"&gt;&lt;b&gt;VALUE_1.1&lt;/b&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td style="border: 0px;"&gt;&lt;b&gt;VALUE_1.2&lt;/b&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td style="border: 0px;"&gt;&lt;b&gt;VALUE_1.3&lt;/b&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td style="border: 0px;"&gt;&lt;b&gt;VALUE_1.4&lt;/b&gt;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style="border: 0px;"&gt;
              &lt;p&gt;&lt;b&gt;VALUE_2&lt;/b&gt;&lt;/p&gt;
              &lt;p&gt;&lt;b&gt;VALUE_3&lt;/b&gt;&lt;/p&gt;
              &lt;p&gt;&lt;b&gt;VALUE_4&lt;/b&gt;&lt;/p&gt;
              &lt;p&gt;&lt;b&gt;VALUE_5&lt;/b&gt;&lt;/p&gt;
          &lt;/td&gt;
          &lt;td style="text-align:center; border:0px;"&gt;
              &lt;svg class="barcode" jsbarcode-format="code128" jsbarcode-value="VALUE_6" jsbarcode-textmargin="0" jsbarcode-margin="0" jsbarcode-height="50" jsbarcode-fontSize="18" jsbarcode-fontoptions="italic"&gt;&lt;/svg&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I've added jquery, jsbarcode and jspdf libraries. This is that I get when I print the whole page (calling the window.print() event with the console and saving it as pdf)
  <a href="https://i.stack.imgur.com/Ut5qH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ut5qH.png" alt="enter image description here"></a></p>
  
  <p>And this is what I have when I send to console the script doc.save("test.pdf");</p>
  
  <p><a href="https://i.stack.imgur.com/GVuCp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GVuCp.png" alt="enter image description here"></a></p>
  
  <p><em>NOTE: I script the doc.save("test.pdf") on the console because I'm being unable to execute the "function(dispose)" code</em></p>
  
  <p>Thanks for the help! </p>
  
  <p><strong>UPDATE:</strong>
  I'm trying the same code without the part of function(dispose), just like this</p>
  
  <pre><code>document.onload = setTimeout(function () {
      JsBarcode(".barcode").init(); 
      var doc = new jsPDF(); 
      var specialElementHandlers = {
          "#bypassme": function (element, renderer) {
              return true
          }
      }; 
      var margins = {
          top: 80,
          bottom: 60,
          left: 40,
          width: 522
      }; 
      var source = $("#content")[0];
      doc.fromHTML(
          source.innerHTML,
          margins.left, 
          margins.top, 
          {
              "width": margins.width,
              "elementHandlers": specialElementHandlers
          }
      );
  
      doc.save("Test.pdf"); 
  }, 500);
  </code></pre>
  
  <p>And now I'm getting the pdf without code anything on the console, but the table is not mapped and the barcode is not showing...</p>