LaTex Export using jsPDF (Updated)

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.2.61/jspdf.min.js"></script>
<script src="https://github.com/niklasvh/html2canvas/releases/download/0.5.0-alpha1/html2canvas.svg.js"></script>
<script src="https://github.com/niklasvh/html2canvas/releases/download/0.5.0-alpha1/html2canvas.js"></script>
<div id="content">
  When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
</div>

<div>
  <button id="getSnap()">Get PDF</button>
</div>


<script type="text/x-mathjax-config">
  MathJax.Hub.Config({ 
  extensions: ["tex2jax.js"], 
  jax: ["input/TeX", "output/HTML-CSS"], 
  tex2jax: { inlineMath: [ ['$','$'], ["\\(","\\)"] ], 
  displayMath: [ ['$$','$$'], ["\\[","\\]"] ], 
  processEscapes: true }, 
  "HTML-CSS": { availableFonts: ["TeX"] } 
  });
</script>

<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>

TypeScript

//Add event listener
document.getElementById("getPdf").addEventListener("click", getSnap);


function getSnap() {
  html2canvas(document.getElementById("content"), {
    onrendered: function(canvas) {
      var imgData = canvas.toDataURL('https://www.google.co.in/imgres?imgurl=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2F8%2F8c%2FIndianStub.png&imgrefurl=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FFile%3AIndianStub.png&docid=kz2gpRKPfGJcdM&tbnid=n3cd2-jFdrkd0M%3A&vet=10ahUKEwjm4_Grp7HeAhXBQo8KHelGARgQMwhrKAIwAg..i&w=2474&h=2695&bih=608&biw=1366&q=png%20images&ved=0ahUKEwjm4_Grp7HeAhXBQo8KHelGARgQMwhrKAIwAg&iact=mrc&uact=8');

      // Generate PDF
      var doc = new jsPDF('p', 'pt', 'a4');
      doc.addImage(imgData, 'PNG', 0, 0, canvas.width, canvas.height);
      doc.save('test.pdf');
    }
  });
}