title: Java convert Html to Image
body: <p>I generated a Html with information of my client, so that he can attach them to your website or email.
  But some clients asked me to generate an image and not the html. I used the code below to generate the image, and it went well, but the image contained in the html is not being generated. When I open the HTML code in browser it works correctly, but when I generated the image from html, it generates only text and breaks the image.</p>
  
  <hr>
  
  <pre><code>public static void main(String[] args) throws Exception {
  String html = "&lt;body lang=PT-BR style='tab-interval:35.4pt'&gt;&lt;img src='http://nxcache.nexon.net/all/v1.5.2/img/gnt/games-dropdown/maplestory.jpg'&gt;&lt;/body&gt;";
  
  int width = 600, height = 200;
  
  BufferedImage image = GraphicsEnvironment.getLocalGraphicsEnvironment()
      .getDefaultScreenDevice().getDefaultConfiguration()
      .createCompatibleImage(width, height);
  
  Graphics graphics = image.createGraphics();
  
  JEditorPane jep = new JEditorPane("text/html", html);
  jep.setSize(width, height);
  jep.print(graphics);
  
  ImageIO.write(image, "png", new File("C:\\Users\\MYUSER\\Documents\\NetBeansProjects\\HtmlToImage\\Image.png"));
  </code></pre>
  
  <p>Does anyone have any idea what might be happening?</p>
  
  <p>This is my problem in picture. --> <a href="https://i.stack.imgur.com/FZSHA.png" rel="nofollow noreferrer">Erro</a></p>
  
  <p>project on git: <a href="http://github.com/dragoso/HtmlToImage" rel="nofollow noreferrer">github</a></p>