title: Export graph to pdf use jquery flot
body: <p>I had a problem about export more graphs which used <code>jquery flot</code> to <code>pdf</code></p>
  
  <p>I used <code>html2canvas.js</code> and <code>jspdf-min.js</code> to export <code>graphs</code> to <code>pdf</code>, but i had two problems:</p>
  
  <p><strong>First</strong>, it exported to <code>pdf</code> too ugly.</p>
  
  <p><strong>Second</strong>, i want to export two graphs inside <strong>one page</strong>, but it exported to two pages.</p>
  
  <p>Here my code:</p>
  
  <pre><code>var _canvas = null;
  $(function() {
    $("#id_generate_pdf").on("click", function (e) {
      window.allcanvas = [];
      var allcontainers = $('[id^="flot-placeholder"]');
  
      allcontainers.each(function (index, elem) {
        html2canvas($(elem).get(0), {
          onrendered: function (canvas) {
            window.allcanvas.push(canvas);
            if(allcontainers.length == allcanvas.length){
              finalpdf();
            }
          }
        });
      });
    });
  
    finalpdf = function(){
      var doc = new jsPDF('landscape');
      for(var i = 0; i&lt; allcanvas.length; i++){
        var imgData = allcanvas[i].toDataURL('image/jpeg');
        doc.addImage(imgData, 'JPEG', 10, 10, 280, 65);
        if(i != allcanvas.length-1) {
          doc.addPage();
        }
      }
      doc.save('testingPDF.pdf');
    };
  });
  </code></pre>
  
  <p>Here is my demo: <a href="http://jsfiddle.net/g2CTz/514/" rel="nofollow noreferrer">My demo code</a></p>
  
  <p>Hope every body can support me. Thank you very much.</p>
  
  <p><strong>Update</strong>: </p>
  
  <p>I want to export <code>pdf</code> and this <code>pdf</code> include this text same as <code>image</code> which i attached.</p>
  
  <p>I don't know how to do that. Please give me some ideas or some advises. Thank you very much.</p>
  
  <p><a href="http://jsfiddle.net/g2CTz/516/" rel="nofollow noreferrer">My demo code update</a></p>
  
  <p><a href="https://i.stack.imgur.com/CnLuF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CnLuF.png" alt="enter image description here"></a>  </p>