title: TypeError while generating pdf with pdfmake
body: <p>Here is my code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var url = 'localhost:8080/chartGenerator';
   function myFunction() {
   var docDef={ content: [
      'This is an sample PDF printed with pdfMake',
      {
          image: getBinaryResource(url)
      }
      ]
  
  
  }
   pdfMake.createPdf(docDef).download('optionalName.pdf');
  }
  
  function getBinaryResource(url){
       var req = new XMLHttpRequest();
      req.open("GET", url, false);
      req.overrideMimeType('text/plain; charset=x-user-defined');
  
      req.send(null);
      if (req.status == 200) {
          return req.responseText.replace(/^data:image\/(png|jpg);base64,/, "");
      } else return null
  
  }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>I need to generate a pdf document with an image that I get from the server, but I have the following error :TypeError: r is undefined.</p>
  
  <p>Could you help me to resolve this issue.</p>