3

I made a report by help of Stimulreport and want to show my image that came from database in my report.

the image is in byte[] format.

How can I do it?

Thanks.

Amin Jalali
  • 320
  • 1
  • 5
  • 15

2 Answers2

2

You can use the following expression in the ImageData property of Image component:

{StiImageHelper.GetImageFromObject(your_byte_array)}
Ishma
  • 86
  • 3
  • 2
    I found it! there is no need to do any extra thing. we can pass the byte[] to the stimulsoft and place an imagebox to the report. it automatically place the image. Thanks. – Amin Jalali Aug 14 '12 at 12:21
  • I mentioned that there is no need to do any extra thing. We can place an ImageBox in report design step and pass our byte[] to Stimulsoft exactly as we do for other fields_text, number and etc_ . – Amin Jalali Sep 22 '12 at 06:24
  • @Amin This is not a clear answer, As Steve said if you find some solutions or exact answer you should post it separately with clear descriptions and mark it as answer. Unfortunately I can't down vote your question because it is good and some user may need it. Thanks and hope you do that. – QMaster Feb 09 '16 at 10:32
0

I have a test table like :

enter image description here

and a test stimulsoft report like :

enter image description here

and the code below is how I send the pic from sql server to stimulsoft and make a pdf file of the report :

protected void btnPrint_Click(object sender, EventArgs e)
    {
        SqlCommand myCommand = new SqlCommand("SELECT * FROM Product_Pipe_QR", new SqlConnection("my connection string"));
        SqlDataAdapter dataAdapter = new SqlDataAdapter(myCommand);
        DataSet dataSet = new DataSet("QR");
        dataAdapter.Fill(dataSet);

        StiReport stiReport = new StiReport();
        string path = "~/Report/Product/QR.mrt";
        stiReport.Load(Server.MapPath(path));

        stiReport.RegData(dataSet);

        stiReport.Render();

        if (!Directory.Exists(Server.MapPath("~/Report/PDF")))
            Directory.CreateDirectory(Server.MapPath("~/Report/PDF"));
        string ReportFileName = "Pipe_Report.pdf";
        stiReport.ExportDocument(StiExportFormat.Pdf, ReportFileName);
        FileStream file = File.Open(ReportFileName, FileMode.Open);
        Response.Clear();
        Response.AddHeader("Content-Disposition", "attachment; filename=" + ReportFileName);
        Response.AddHeader("Content-Length", file.Length.ToString());
        Response.ContentType = "application/pdf";
        file.Close();
        Response.WriteFile(ReportFileName);
    }

both UniqueSerial and QRImage in stimulsoft dictionary are string and QRImage in database is image type.

Nima Derakhshanjan
  • 1,380
  • 9
  • 24
  • 37