Im trying to convert DataGridView data with image column which is filtered from my SQL Db into a PDF file
in C# I wrote this code using iTextSharp!
but I got Error like this: "unable to cast object of type System.Drawing.bitmap to type system byte[]"
Can anyone help me out kindly?
Here is My Code:
Thanks !!!
- foreach (DataGridViewCell cell in row.Cells)
- {
- if(row.Cells[0].Value!= null)
- {
- pdfTable.AddCell(row.Cells[0].Value.ToString());
- }
-
- if (row.Cells[1].Value != null)
- {
- byte[] img = (byte[])row.Cells[1].Value;
- pdfTable.AddCell(iTextSharp.text.Image.GetInstance(img));
- }
- }