[英]How to create a iTextSharp.text.Image object startng to a System.Drawing.Bitmap object?
I am pretty new in iTextSharp (the C# version of iText ): 我是iTextSharp ( iText的C#版本)的新手:
I have something like this: 我有这样的事情:
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 });
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. 正如你所看到的,我有经典的System.Drawing.Bitmap immage命名为bitmap ,我希望将它放在PDF文档表的单元格中。
The problem is that this line is signed as error: 问题是此行被签名为错误:
iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(bitmap);
The error is: 错误是:
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 错误75'iTextSharp.text.Image.GetInstance(iTextSharp.text.Image)'的最佳重载方法匹配有一些无效的参数c:\\ Develop \\ EarlyWarning \\ public \\ Implementazione \\ Ver2 \\ PdfReport \\ PdfVulnerability.cs 120 27 PdfReport
So I think that I need to obtain an iTextSharp.text.Image object from a classic System.Drawing.Bitmap object. 所以我认为我需要从经典的System.Drawing.Bitmap对象中获取iTextSharp.text.Image对象。
What can I do to do it? 我该怎么办呢? I am going crazy trying to do it. 我疯狂地试图去做。
Tnx TNX
There are no overloads that take just a System.Drawing.Image
. 没有重载只需要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)
The first one is probably the best choice and I'm 99% sure you can pass null
for the color
parameter. 第一个可能是最好的选择,我99%肯定你可以为color
参数传递null
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.