我正在使用WebRenderer将 HTML5 页面导出为服务器上的图像。问题是唯一支持HTML5的版本是swing版本。但是,我可以使用 swing 版本中的 jar 文件并创建一个新的 IMozillaBrowserCanvas
对象,而不将其链接到 JFrame/JPanel 并让它在没有 GUI 的情况下转换 html5 页面。
仅使用IMozillaBrowserCanvas
时,swing版本和服务器版本有什么区别吗?我能找到的唯一信息是:
The WebRenderer Server Edition 4.0 scales better in server and headless environments than any other Java browser SDK due to the fact that rendering is not performed on the Swing Thread. Keeping rendering off the Swing Thread, and multi-threading the rendering leads to major improvements in scalability. [Source]
此外,当从 BrowserFactory
类调用 spawnMozilla()
方法时,后端发生了什么?据我所知,这只是一个纯java浏览器,并没有在后台运行xserver。
最佳答案
我已经联系了WebRenderer的开发者。他说:
There are mostly internal architectural differences between the Server and Swing Editions of WebRenderer. The Server Edition was designed primarily for creating images of pages, whereas the Swing Edition is a fully functional browser. However, this does not prevent the Swing Edition from being used efficiently to generate page images.
The API is similar, although the Server has convenience methods for different sizes/types of image generation, and the Swing Edition has more features available. The version of the underlying Mozilla browser is much more recent in the Swing Edition, so it is capable of rendering pages that make use of technologies such as HTML5.
While the rendering is all done in Java, the Mozilla component needs to be handled natively for each platform. It does not run an xserver, but the spawnMozilla() call will set up these native components, they are extracted to the .webrendererswing6 directory in the user home directory by default.
关于java - WebRenderer Swing 和服务器版,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11362300/