List of usage examples for javax.swing JEditorPane print
public void print(Graphics g)
Graphics
. From source file:Main.java
public static void main(String[] args) throws Exception { String html = "<h1>Hello, world.</h1>"; int width = 200, height = 100; BufferedImage image = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getDefaultConfiguration().createCompatibleImage(width, height); Graphics graphics = image.createGraphics(); JEditorPane jep = new JEditorPane("text/html", html); jep.setSize(width, height);/*from w ww .j a v a 2 s . c om*/ jep.print(graphics); ImageIO.write(image, "png", new File("Image.png")); }