title: JsPDF - Change filename based on a label value the download the PDF
body: <p>I used jsPDF and html2canvas to take a screenshot of a div and add it to PDF then download it. My code is working just fine but what I need is to change the PDF filename based on a label value inside my div.</p>
  
  <p>For example:</p>
  
  <p>The label value is "John_Simith", the PDF filename I want to be John_Simith.pdf, but when the label value became "Sarah" I need the filename to be Sarah.pdf.</p>
  
  <p>Here is my Javascript:</p>
  
  <pre class="lang-js prettyprint-override"><code>function getPDF() {
  
              var HTML_Width = $(".canvas_div_pdf").width();
              var HTML_Height = $(".canvas_div_pdf").height();
              var top_left_margin = 15;
              var PDF_Width = HTML_Width;
              var PDF_Height = HTML_Height;
              var canvas_image_width = HTML_Width;
              var canvas_image_height = HTML_Height * 1.1;
  
              var totalPDFPages = Math.ceil(HTML_Height / PDF_Height) - 1;
  
  
              html2canvas($(".canvas_div_pdf")[0], { allowTaint: true }).then(function (canvas) {
                  canvas.getContext('2d');
  
                  console.log(canvas.height + "  " + canvas.width);
  
  
                  var imgData = canvas.toDataURL("image/jpeg", 1.0);
                  var pdf = new jsPDF('p', 'pt', [PDF_Width, PDF_Height]);
                  pdf.addImage(imgData, 'JPG', top_left_margin, top_left_margin, canvas_image_width, canvas_image_height);
  
  
                  for (var i = 1; i &lt;= totalPDFPages; i++) {
                      pdf.addPage(PDF_Width, PDF_Height);
                      pdf.addImage(imgData, 'JPG', 0, 0, canvas_image_width, canvas_image_height);
                  }
  
  
  
                  pdf.save("Sample.pdf");
                  location.reload(true);
              });
          };
  </code></pre>
  
  
  
  <p>I'm not sure how to do this, so please I need your advice and much appreciated.</p>