title: pdfmake base64 image callback
body: <p>I have to work with pdfmake to build a pdf preview within my laravel application. I am a javascript noob and going nuts to generate the dataURI for an image in b. Hope you can help me out.
  How can I get that generated base64 into my docdefinition?</p>
  
  <pre><code>    function convertImageToDataURL(src, callback, outputFormat) {
          // Create an Image object
          var img = new Image();
          // Add CORS approval to prevent a tainted canvas
          img.crossOrigin = 'Anonymous';
          img.onload = function() {
              var canvas = document.createElement('CANVAS');
              var ctx = canvas.getContext('2d');
              var dataURL;
              canvas.height = this.naturalHeight;
              canvas.width = this.naturalWidth;
              ctx.drawImage(this, 0, 0);
              dataURL = canvas.toDataURL(outputFormat);
              callback(dataURL);
  
              // Mark the canvas to be ready for garbage
              // collection
              canvas = null;
          };
  
          img.src = src;
          // make sure the load event fires for cached images too
          if (img.complete || img.complete === undefined) {
              // Flush cache
              img.src = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==';
              // Try again
              img.src = src;
          }
      }
  
      convertImageToDataURL(
          '{{asset('storage/'.$report-&gt;author-&gt;enterprises-&gt;first()-&gt;logo_image)}}',
          function(dataUrl) {
              // console.log('RESULT:', dataUrl);
              // Put dataUrl into DocDefinition here!?!?
              // return dataUrl is undefined
          }
      );`
  </code></pre>