title: Html code to Png image
body: <p>I made a web application which allow the user to create an image dynamically in JavaScript.<br>
  It use jQuery to allow the user to place div, resize them and drag them into a <code>&lt;div&gt;</code> Container.<br>
  When the user finished to place all div, he can press the "Generate" button which send the <code>&lt;div&gt;</code> Container outerHTML code into a local database.
  Then the user can use another script, in php, and past in parameter the id in the database of which render he want to display, then the php script create a page using the code in the database.</p>
  
  <p>My problem is now I want to take the code of this generated html page, then convert it into a png image.</p>
  
  <p>I looked at some other posts and found something interesting : Phantom.js</p>
  
  <p>But what I tried doesn't seem to work. Here is my code :</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Test&lt;/title&gt;
          &lt;LINK rel='stylesheet' type='text/css' href='style.css'&gt;
          &lt;script type='text/javascript' src='jquery/jquery.js'&gt;&lt;/script&gt;
          &lt;script type='text/javascript' src='jquery-ui/jquery-ui.js'&gt;&lt;/script&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
      &lt;script&gt;
          var page = require('webpage').create();
          page.open('http://10.237.35.10/maxime/affichage.php?afficheur=0', function() {
              page.render('affichageTest.png');
              phantom.exit();
          });
      &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>So we have the database with the div outerHTML code contained at the id '0'.
  "affichage.php" take in parameter a variable "afficheur" then it ask the database to get the code from this variable. For example, afficheur=0 will return the div code contained in the database at the id=0.<br>
  When I go to "<a href="http://10.237.35.10/maxime/affichage.php?afficheur=0" rel="nofollow">http://10.237.35.10/maxime/affichage.php?afficheur=0</a>" I have a html page with the render I want. But when I try to run the script I'd posted higher, I haven't any "affichageTest.png" rendered in my folder.</p>
  
  <p>What do I have to do? Do I have to import anything else to run Phantom.js? Or maybe I need to add something to my code?</p>