I am pretty new in iTextSharp (the C# version of iText):
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.
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
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
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)
The first one is probably the best choice and I'm 99% sure you can pass null
for the color
parameter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With