Reputation: 321
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.
Upvotes: 3
Views: 3916
Reputation: 1404
I have a test table like :
and a test stimulsoft report like :
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
.
Upvotes: 0
Reputation: 86
You can use the following expression in the ImageData property of Image component:
{StiImageHelper.GetImageFromObject(your_byte_array)}
Upvotes: 2