title: How to send pdf generated from screen shot in JavaScript
body: <p><strong>Objective</strong> - Take a screenshot of the page, then make pdf of that and send that pdf to the spring boot backend.</p>
  <p>I have implemented the functionality to take the screenshot and convert it into pdf using <code>html2canvas</code> and <code>pdfmake</code> JavaScript libraries.</p>
  <p><strong>Issue</strong> - I don't know how to send the generated pdf to the backend. I got to know about base64 encode but I am still confused.</p>
  <p><strong>Code</strong> -</p>
  <pre><code>function takeSS() {
      html2canvas(document.body, {
          onrendered: function(canvas) {
              var data = canvas.toDataURL();
              var docDefinition = {
                  content: [{
                      image: data,
                      width: 900,
                  }]
              };
              pdfMake.createPdf(docDefinition).download(&quot;test.pdf&quot;); // to download
          }
      });
  }
  </code></pre>
  <p>The above code is taking the screenshot of the page converting it to pdf and downloading it.
  Instead of downloading it, how can I send this pdf to backend?
  Do I need to base64 encode <code>canvas.toDataURL()</code>?</p>
  <p><strong>Edit</strong> Changed my code - <a href="https://jsfiddle.net/ChitrangSharma07/pt9sjvka/1/" rel="nofollow noreferrer">jsFiddle</a></p>