title: function doc.save width jspdf
body: <p>In fact we generate from an HTML file administrative documents for each customer.
  On the other hand this pdf generated will be saved to a specific folder on the server to be sent to the customer concerned.</p>
  
  <p>Can I serve the backup path by doc.save order?
  My code:</p>
  
  <pre><code>function createpdf() {
  var canvasToImage = function(canvas){
      var img = new Image();
      var dataURL = canvas.toDataURL('image/png');
      img.src = dataURL;
      return img;
  };
  var a4  =[595.28,2000];
  var canvasShiftImage = function(oldCanvas,shiftAmt){
      shiftAmt = parseInt(shiftAmt) || 0;
      if(!shiftAmt){ return oldCanvas; }
  
      var newCanvas = document.createElement('canvas');
      newCanvas.height = oldCanvas.height - shiftAmt;
      newCanvas.width = oldCanvas.width;
      var ctx = newCanvas.getContext('2d');
  
      var img = canvasToImage(oldCanvas);
      ctx.drawImage(img,0, shiftAmt, img.width, img.height, 0, 0, img.width, img.height);
  
      return newCanvas;
  };
  
  
  var canvasToImageSuccess = function(canvas){
      var pdf = new jsPDF('p','px','letter'),
          pdfInternals = pdf.internal,
          pdfPageSize = pdfInternals.pageSize,
          pdfScaleFactor = pdfInternals.scaleFactor,
          pdfPageWidth = pdfPageSize.width,
          pdfPageHeight = pdfPageSize.height,
          totalPdfHeight = 0,
          htmlPageHeight = canvas.height,
          htmlScaleFactor = canvas.width / (pdfPageWidth * pdfScaleFactor),
          safetyNet = 0;
  
      while(totalPdfHeight &lt; htmlPageHeight &amp;&amp; safetyNet &lt; 15){
          var newCanvas = canvasShiftImage(canvas, totalPdfHeight);
          pdf.addImage(newCanvas, 'png',0, 0, pdfPageWidth, 0, null, 'NONE');
  
          totalPdfHeight += (pdfPageHeight * pdfScaleFactor * htmlScaleFactor );
  
          if(totalPdfHeight &lt; htmlPageHeight){
              pdf.addPage();
          }
          safetyNet++;
      }
  
      pdf.save('&lt;?php echo $mavariable?&gt;.pdf');
  };
  
  html2canvas($('main')[0], {
      onrendered: function(canvas){
          canvasToImageSuccess(canvas);
      }
  });
  </code></pre>
  
  <p>}</p>