Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

insert dynamic images in a crystal reports page from the image folder

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#?

like image 351
Kiran Solkar Avatar asked Nov 13 '22 23:11

Kiran Solkar


1 Answers

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");
        }
    }
like image 61
Kiran Solkar Avatar answered Nov 15 '22 13:11

Kiran Solkar