Other Issues - How to print Picture in Crystal Report 8.5 |
| Swapnil Salunke replied to Atheeq Ahmed at 16-Jun-08 01:35 |
 | Hello Atheeq Ahmed
You can try this way try { DataTable dt = new DataTable(); DataRow drow; dt.Columns.Add("Image", System.Type.GetType("System.Byte[]")); drow = dt.NewRow; FileStream fs; BinaryReader br; if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "10157.Jpg")) { fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "10157.Jpg", FileMode.Open); } else { fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "NoPhoto.jpg", FileMode.Open); } br = new BinaryReader(fs); byte[] imgbyte = new byte[fs.Length + 1]; imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length))); drow(0) = imgbyte; dt.Rows.Add(drow); br.Close(); fs.Close(); CrystalReport1 rptobj = new CrystalReport1(); rptobj.SetDataSource(dt); CrystalReportViewer1.ReportSource = rptobj; } catch (Exception ex) { Interaction.MsgBox("Missing 10157.jpg or nophoto.jpg in application folder"); }
|