如何创建一个iTextSharp.text.Image对象startng到System.Drawing.Bitmap对象? [英] How to create a iTextSharp.text.Image object startng to a System.Drawing.Bitmap object?

查看:1463
本文介绍了如何创建一个iTextSharp.text.Image对象startng到System.Drawing.Bitmap对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 iTextSharp iText 的C#版本)中的新手:

I am pretty new in iTextSharp (the C# version of iText):

我有类似的东西这个:

System.Drawing.Bitmap bitmap = (System.Drawing.Bitmap)ChartHelper.GetPdfChart((int)currentVuln.UrgencyRating * 10);

iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(bitmap);

vulnerabilityDetailsTable.AddCell(new PdfPCell(img) { Border = PdfPCell.RIGHT_BORDER, BorderColor = new BaseColor(79, 129, 189), BorderWidth = 1, Padding = 5, MinimumHeight = 30, PaddingTop = 10 });  

如你所见,我有经典的 System.Drawing.Bitmap immage命名位图,我想把它放在PDF文档表的单元格中。

As you can see I have classic System.Drawing.Bitmap immage named bitmap and I want put it inside a cell of a PDF document table.

问题是此行被签名为错误:

The problem is that this line is signed as error:

iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(bitmap);

错误是:


错误75
的最佳重载方法匹配'iTextSharp.text.Image.GetInstance(iTextSharp.text.Image)'有一些
无效
参数c:\Develop \EarlyWarning\public\Implementazione\Ver2\PdfReport\PdfVulnerability.cs 120 27 PdfReport

Error 75 The best overloaded method match for 'iTextSharp.text.Image.GetInstance(iTextSharp.text.Image)' has some invalid arguments c:\Develop\EarlyWarning\public\Implementazione\Ver2\PdfReport\PdfVulnerability.cs 120 27 PdfReport

所以我认为我需要从经典的 System.Drawing.Bitmap 对象中获取 iTextSharp.text.Image 对象。

So I think that I need to obtain an iTextSharp.text.Image object from a classic System.Drawing.Bitmap object.

我该怎么办?我疯狂地试图这样做。

What can I do to do it? I am going crazy trying to do it.

Tnx

推荐答案

没有重载只需 System.Drawing.Image 。你需要使用其中一个:

There are no overloads that take just a System.Drawing.Image. You need to used one of these:

GetInstance(System.Drawing.Image image, BaseColor color)
GetInstance(System.Drawing.Image image, BaseColor color, bool forceBW)
GetInstance(System.Drawing.Image image, System.Drawing.Imaging.ImageFormat format)

第一个可能是最好的选择,我99%肯定你可以为<$ c传递 null c $ c> color 参数。

The first one is probably the best choice and I'm 99% sure you can pass null for the color parameter.

这篇关于如何创建一个iTextSharp.text.Image对象startng到System.Drawing.Bitmap对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆