从 Draw2D 画布创建 PDF
我正在寻找一种从 Draw2D 画布构建 PDF 的方法。我相信我已经从 Java2D 中找到了一种方法来做到这一点,但在 Draw2D 中却没有。其中涉及许多图形元素(以及文本),因此我认为我无法走 XSLT 路线。有人有什么建议吗?
I'm looking for a way to build a PDF from a Draw2D canvas. I believe I've seen a way to do this from Java2D, but not Draw2D. There are many graphical elements involved (as well as text) so I don't think I can go the XSLT route. Does anyone have any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您可以使用“jPod”取得成功。
它附带了一个如何使用其“CSCreator”创建 PDF 内容的简单示例,该示例将 PDF 图形操作原语作为 API 发布。虽然我不使用draw2d,但我认为映射到这个API应该不难。
大致应该像这样
Maybe you can succeed using "jPod".
It comes with a simple example how to create PDF content using its "CSCreator", which publishes the PDF graphics operation primitives as an API. While i do not use draw2d, i assume it shouldn't be to hard to map to this API.
Roughly it should go like this
iText 是一个用于从 java 应用程序创建 PDF 的库。 iText 实现了 Graphics2D 类的适配器,请参阅此。因此您可以将任何 AWT/Swing 组件绘制到 PDF 中。
Eclipse Graphiti 包含另一个 适配器。它将draw2d Graphics 调整为awt 的Graphics2D。您可以下载它,也许可以根据您的需要进行一些编辑。因此,使用这些适配器,您可以将根图绘制到 PDF 中。它有效,我已经尝试过。
iText is a library for creating PDF from java application. iText implements its adapter for Graphics2D class, see this. So you can draw any AWT/Swing component to the PDF.
Eclipse Graphiti contains another adapter. It adapts draw2d Graphics to awt's Graphics2D. You can download it and maybe little edit for your needs. So using those adapters you can draw your root figure to the PDF. It works, I have tried that.