title: JSPDF Saved file locally gives document [110] error with Acrobat
body: <p>I have the following JavaScript code <a href="https://jsfiddle.net/d72sgwrc/5/" rel="nofollow noreferrer">https://jsfiddle.net/d72sgwrc/5/</a> Which suppose to save the image of my screen turn it into Canvas and save it into PDF. Once the file is downloaded on my local machine I am able to view the PDF file within the browser but if I want to open the file on Acrobat PDF viewer I get the following error "There was and error Processing a page. There was a problem readying this document(110). my HTML page is just a table with bunch of generated number.  </p>
  
  <p>JS</p>
  
  <pre><code>function exportPDF() {
  var pdf = new jsPDF('l', 'px'),
      source = $('body')[0];
  var canvasToImage = function(canvas) {
      var img = new Image();
      var dataURL = canvas.toDataURL('image/png');
      img.src = dataURL;
      return img;
  };
  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('l', 'px'),
          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('test.PDF');
  };
  html2canvas(source, {
      onrendered: function(canvas) {
          canvasToImageSuccess(canvas);
      }
  });
  }
  
      exportPDF();
  </code></pre>
  
  <p>HTML is in JSFiddle as I cant paste it here, I get error <a href="https://jsfiddle.net/d72sgwrc/5/" rel="nofollow noreferrer">https://jsfiddle.net/d72sgwrc/5/</a></p>
  
  <p>I am using the following JS libraries<br>
  <a href="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.debug.js" rel="nofollow noreferrer">https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.debug.js</a></p>
  
  <p><a href="https://fastcdn.org/FileSaver.js/1.1.20151003/FileSaver.min.js" rel="nofollow noreferrer">https://fastcdn.org/FileSaver.js/1.1.20151003/FileSaver.min.js</a></p>
  
  <p><a href="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js" rel="nofollow noreferrer">https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js</a></p>
  
  <p><a href="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js" rel="nofollow noreferrer">https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js</a></p>