5

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

0

2 Answers 2

1

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");
        }
    }
1
  • 1
    What exactly are you creating inside CreateTable()? DsImages? Jun 21, 2013 at 14:38
0

In CR you can do this by: Inserting a placeholder image in your report at the position and size you want it. Right-click on it and select "Format Graphic" -> Go to the "Picture" tab -> Enter a formula in the "Graphic Location" that will return the desired file path.

2
  • 1
    Works with CR 2008? I'm putting a image, right-clicking, selecting "Format Object" (there is no Format Graphic)... and there is no "Graphic Location" inside Picture tab. Help me, please. Jun 21, 2013 at 14:27
  • @NickeDaSilvaManarin Yes, this is in CR2008. When right-clicking a picture you should not have a "Format Object" option, only "Format Graphic". Make sure you haven't selected multiple objects at once.
    – Ryan
    Jun 21, 2013 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.