使用 ITextSharp 绘制矢量图形
我听说 ITextSharp 不支持 JAVA2D 类,这是否意味着我无法从客户端数据库导入向量点以“打印”到 ITextSharp 应用程序?
在进一步提出这个建议之前,我真的很想找到这个问题的答案。 有人有这方面的真实经历吗?
I have heard that ITextSharp does not have support for the JAVA2D class, does this mean that i cant import vector points from a clients databas to "print" to a ITextSharp application?
I would relly like to find answer to this before going further with this suggestion.
Anyone have real experiences of this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然您确实无法将 JAVA2D 与 iTextSharp 一起使用,但您仍然可以通过直接写入
PdfWriter.DirectContent
对象,以 PDF 本机方式绘制矢量图形。它支持您期望从矢量绘图中获得的所有标准MoveTo()
、LineTo()
、CurveTo()
等方法程序。下面是一个针对 iTextSharp 5.1.1.0 的完整工作 VB.Net WinForms 应用程序,展示了一些简单的用途。编辑
顺便说一句,虽然你不能使用JAVA2D(这显然是Java并且不能与.Net一起工作),但你可以使用标准的
System.Drawing.Image 类并将其传递给
iTextSharp.text.Image.GetInstance()
静态方法。不幸的是,System.Drawing.Image
是一个光栅/位图对象,因此在这种情况下它对您没有帮助。While it is true that you can't use JAVA2D with iTextSharp you can still draw vector graphics in a PDF-native way by writing directly to the
PdfWriter.DirectContent
object. It supports all of the standardMoveTo()
,LineTo()
,CurveTo()
, etc methods that you'd expect from a vector drawing program. Below is a full-working VB.Net WinForms app targeting iTextSharp 5.1.1.0 the shows off some simple uses.EDIT
Incidentally, although you can't use JAVA2D (which is obviously Java and wouldn't work with .Net) you can create iTextSharp images using the standard
System.Drawing.Image
class and passing it toiTextSharp.text.Image.GetInstance()
static method. UnfortunatelySystem.Drawing.Image
is a raster/bitmap object so it won't help you in this case.