title: How to execute page.render inside page.evaluate?
body: <p>I do want to render my page and exit PhantomJS in the evaluate function, because I want to trigger it when a specific event is fired.</p>
  
  <p>I've tried something like this:</p>
  
  <pre><code>page.evaluate(page, function (page, phantom) {
  
      //do some stuff on my page
  
      //i want to execute this in an eventhandler of my page though thats not the problem
      page.render('imgName.png'); 
      page.render('pdfName.pdf');
      phantom.exit();
  
  }, page, phantom);
  </code></pre>
  
  <p>This doesn't work in my example, because <code>page.render</code> seems to be undefined. Maybe there is a serializer for the arguments which is not serializing functions of the obj?</p>
  
  <p>Is this even possible? Does anyone know a solution for my issue? </p>
  
  <p>I know I could set a while loop in my evaluate function and prevent its termination and do this page render stuff outside afterwards. I don't like this though.</p>