Is there a way to insert images dynamically in a Crystal Reports page from an images folder?
The exact requirement is to display a company's logo at the top of every crystal report page and when they change, i.e when you have a new logo , you only change the image(.jpg) in the images folder and the corresponding image in all the reports should change.
How do I achieve this in C#?
I'm posting the answer i got, hope this would be helpful for others.
private void getImage()
{
FileStream fs;
fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "img\\cube.png", FileMode.Open);
BinaryReader BinRed = new BinaryReader(fs);
try
{
CreateTable();
DataRow dr = this.DsImages.Tables["images"].NewRow();
dr["image"] = BinRed.ReadBytes((int)BinRed.BaseStream.Length);
this.DsImages.Tables["images"].Rows.Add(dr);
//FilStr.Close();
BinRed.Close();
DynamicImageExample DyImg = new DynamicImageExample();
DyImg.SetDataSource(this.DsImages);
this.crystalReportViewer1.ReportSource = DyImg;
}
catch (Exception er)
{
MessageBox.Show(er.Message, "Error");
}
}
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