@Test public void testGenerateImage() throws ScriptException { HtmlToImageConverter.decorateHtml("helllo"); InputStream image = HtmlToImageConverter.generateImage("jnnkanknva"); Assert.assertNotNull(image); }
public static InputStream generateImage(String htmlAsText){ InputStream inputStream; try{ imageGenerator.loadHtml(htmlAsText); BufferedImage input = imageGenerator.getBufferedImage(); ByteArrayOutputStream output = new ByteArrayOutputStream(); ImageIO.write(input, "png", output); inputStream = new ByteArrayInputStream(output.toByteArray()); }catch(Exception e){ e.printStackTrace(); throw new ImageGenerationException(e.getMessage()); } return inputStream; }
HtmlToImageConverter { public static InputStream generateImage(String htmlAsText){ InputStream inputStream; try{ imageGenerator.loadHtml(htmlAsText); BufferedImage input = imageGenerator.getBufferedImage(); ByteArrayOutputStream output = new ByteArrayOutputStream(); ImageIO.write(input, "png", output); inputStream = new ByteArrayInputStream(output.toByteArray()); }catch(Exception e){ e.printStackTrace(); throw new ImageGenerationException(e.getMessage()); } return inputStream; } }
HtmlToImageConverter { public static InputStream generateImage(String htmlAsText){ InputStream inputStream; try{ imageGenerator.loadHtml(htmlAsText); BufferedImage input = imageGenerator.getBufferedImage(); ByteArrayOutputStream output = new ByteArrayOutputStream(); ImageIO.write(input, "png", output); inputStream = new ByteArrayInputStream(output.toByteArray()); }catch(Exception e){ e.printStackTrace(); throw new ImageGenerationException(e.getMessage()); } return inputStream; }  }
HtmlToImageConverter { public static InputStream generateImage(String htmlAsText){ InputStream inputStream; try{ imageGenerator.loadHtml(htmlAsText); BufferedImage input = imageGenerator.getBufferedImage(); ByteArrayOutputStream output = new ByteArrayOutputStream(); ImageIO.write(input, "png", output); inputStream = new ByteArrayInputStream(output.toByteArray()); }catch(Exception e){ e.printStackTrace(); throw new ImageGenerationException(e.getMessage()); } return inputStream; }  static InputStream generateImage(String htmlAsText); static String decorateHtml(String html); }
HtmlToImageConverter { public static InputStream generateImage(String htmlAsText){ InputStream inputStream; try{ imageGenerator.loadHtml(htmlAsText); BufferedImage input = imageGenerator.getBufferedImage(); ByteArrayOutputStream output = new ByteArrayOutputStream(); ImageIO.write(input, "png", output); inputStream = new ByteArrayInputStream(output.toByteArray()); }catch(Exception e){ e.printStackTrace(); throw new ImageGenerationException(e.getMessage()); } return inputStream; }  static InputStream generateImage(String htmlAsText); static String decorateHtml(String html); static HtmlImageGenerator imageGenerator; }