title: Export Canvas content to PDF
body: <p>I am working on something using HTML5 Canvas.
  It's all working great, except right now, I can export the canvas content to PNG using Canvas2image. But I would like to export it to PDF. I've made some research and I'm pretty sure it's possible...but I can't seem to understand what I need to change in my code to make it work. I've read about a plugin called pdf.js...but I can't figure out how to implent it in my code.</p>
  
  <p>First part :</p>
  
  <pre><code>function showDownloadText() {
          document.getElementById("buttoncontainer").style.display = "none";
          document.getElementById("textdownload").style.display = "block";
      }
  
      function hideDownloadText() {
          document.getElementById("buttoncontainer").style.display = "block";
          document.getElementById("textdownload").style.display = "none";
      }
  
      function convertCanvas(strType) {
          if (strType == "PNG")
              var oImg = Canvas2Image.saveAsPNG(oCanvas, true);
          if (strType == "BMP")
              var oImg = Canvas2Image.saveAsBMP(oCanvas, true);
          if (strType == "JPEG")
              var oImg = Canvas2Image.saveAsJPEG(oCanvas, true);
  
          if (!oImg) {
              alert("Sorry, this browser is not capable of saving " + strType + " files!");
              return false;
          }
  
          oImg.id = "canvasimage";
  
          oImg.style.border = oCanvas.style.border;
          oCanvas.parentNode.replaceChild(oImg, oCanvas);
  
          showDownloadText();
      }
  </code></pre>
  
  <p>And the JS to that saves the image :</p>
  
  <pre><code>    document.getElementById("convertpngbtn").onclick = function() {
          convertCanvas("PNG");
      }
  
      document.getElementById("resetbtn").onclick = function() {
          var oImg = document.getElementById("canvasimage");
          oImg.parentNode.replaceChild(oCanvas, oImg);
  
          hideDownloadText();
      }
  
  }
  </code></pre>