title: Trouble printing a specific div in php with javascript
body: <p>I want to print a specific div without the button showing. When I use document.body the pdf the button is displayed inside. But when i use document.getElementById("customers") all I get is a pdf with black lines. I need some help because I searched and tried many solutions but nothing seems to work.
  Here is my code</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta charset="UTF-8"&gt;
          &lt;title&gt;&lt;/title&gt;
          &lt;script type="text/javascript" src="script.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.0.272/jspdf.debug.js"&gt;&lt;/script&gt;
          &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div id="customers"&gt; &lt;!-- div that contains my table --&gt;
              &lt;table id="tab_customers" class="table table-striped"&gt;
                  &lt;colgroup&gt;
                      &lt;col width="20%"&gt;
                          &lt;col width="20%"&gt;
                              &lt;col width="20%"&gt;
                                  &lt;col width="20%"&gt;
                  &lt;/colgroup&gt;
                  &lt;thead&gt;
                      &lt;tr&gt;
                          &lt;th&gt;Country&lt;/th&gt;
                          &lt;th&gt;Population&lt;/th&gt;
                          &lt;th&gt;Date&lt;/th&gt;
                          &lt;th&gt;Age&lt;/th&gt;
                      &lt;/tr&gt;
                  &lt;/thead&gt;
                  &lt;tbody&gt;
                      &lt;tr&gt;
                          &lt;td&gt;Chinna&lt;/td&gt;
                          &lt;td&gt;1,363,480,000&lt;/td&gt;
                          &lt;td&gt;March 24, 2014&lt;/td&gt;
                          &lt;td&gt;19.1&lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td&gt;India&lt;/td&gt;
                          &lt;td&gt;1,241,900,000&lt;/td&gt;
                          &lt;td&gt;March 24, 2014&lt;/td&gt;
                          &lt;td&gt;17.4&lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/tbody&gt;
              &lt;/table&gt;
          &lt;/div&gt;
          &lt;input type="button" value="save" onclick="javascript:saveAspdf()"/&gt; &lt;!-- call the js function --&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>javascript:</p>
  
  <pre><code>/* js function reffering to jspdf to save a pdf */
      function saveAspdf() {
      var pdf = new jsPDF('p','pt','a4');
      pdf.addHTML(document.getElementById("customers"),function() {
          pdf.save('newDoc.pdf');
      });
      }
  </code></pre>