code: function createDataURIFromElement(element, format) {
      //if element is an image which uses data url definition, just return the dataurl
      if (element.nodeName === 'IMG' && element.hasAttribute('src')) {
        var src = '' + element.getAttribute('src'); //is base64 encoded dataUrl, directly process it
  
        if (src.indexOf('data:image/') === 0) {
          return unescape(src);
        } //it is probably an url, try to load it
  
  
        var tmpImageData = jsPDFAPI.loadFile(src);
  
        if (tmpImageData !== undefined) {
          return btoa(tmpImageData);
        }
      }
  
      if (element.nodeName === 'CANVAS') {
        var canvas = element;
        return element.toDataURL('image/jpeg', 1.0);
      } //absolute fallback method
  
  
      var canvas = document.createElement('canvas');
      canvas.width = element.clientWidth || element.width;
      canvas.height = element.clientHeight || element.height;
      var ctx = canvas.getContext('2d');
  
      if (!ctx) {
        throw 'addImage requires canvas to be supported by browser.';
      }
  
      ctx.drawImage(element, 0, 0, canvas.width, canvas.height);
      return canvas.toDataURL(('' + format).toLowerCase() == 'png' ? 'image/png' : 'image/jpeg');
    }
docs: Image functionality ported from pdf.js