我找到了http://code.google.com/p/flying-saucer/,这应该是我的项目最合适的解决方案。但这些文件似乎只能从文件中读取。
但是我想从代码中呈现我的情况,我不想保存一个临时的XML文件。例如,renderToImageAutoSize in Graphics2DRenderer
静态java.awt.image.BufferedImage renderToImageAutoSize(java.lang.String url,int width,int bufferedImageType)一种静态实用工具方法,用于从文档自动创建图像,其中高度是根据文档内容确定的。
有没有办法让渲染器直接从内存中的HTML代码中读取?
发布于 2012-02-02 15:52:59
Graphics2DRenderer不是实用程序类。您应该创建它的一个新实例。
Graphics2DRenderer gr = new Graphics2DRenderer();
gr.setDocument(doc, uri);
gr.layout(g2, dim);
Rectangle minSize = r.getMinimumSize();
//create new image with this size
gr.render(newG2);请参阅http://today.java.net/pub/a/today/2006/10/31/combine-facelets-and-flying-saucer-renderer.html#xhtml-to-image-conversion
https://stackoverflow.com/questions/9114058
复制相似问题