image in web report

Stimulsoft Reports.NET discussion
Roger
Posts: 10
Joined: Wed May 30, 2007 9:39 am
Location: Dordrecht, The Netherlands

image in web report

Post by Roger »

Hi,

In Designer it is possible to show an image as a header in the report.
Once I copied the report to the website and view it online the image has disappeared.
The Designer offers several ways to include an image in the report.
I have tried them all.

What is the best way to include an image as a header in the report.

Thanks in advance!

roger
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

image in web report

Post by Edward »

The best way to show images in StiWebViewer is ImageURL property. Also please try to increase time of the ServerTimeout property.

Thank you.
james
Posts: 6
Joined: Tue May 05, 2009 4:08 am

image in web report

Post by james »

hi dears,

i have a report with an image to show information of employees in web.
i use ImageURL property to show image, also i save name of image in database.

public void imgEmp__GetImageURL(object sender, Stimulsoft.Report.Events.StiValueEventArgs e)
{
e.Value = HttpContext.Current.Server.MapPath("~/EmpImages/") + ToString(sender, Emp.EmpPhoto);
}

but unfortunately i can't load images in WebViewer.

could you please help me
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

image in web report

Post by Jan »

Hello,

If you enter in ImageURL property path to image it work?

Thank you.
james
Posts: 6
Joined: Tue May 05, 2009 4:08 am

image in web report

Post by james »

thanks a lot

i have exported my report in a C# file and use that in my web application.
i changed code :

this.imgEmployee.ImageURL = new StiImageURLExpression(HttpContext.Current.Server.MapPath("~/EmployeeImages/abc.jpg");

but i could not load image in viewer.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

image in web report

Post by Edward »

Hi James,

Please assign the following property:

Image1.ImageURLValue = "http://www.myurl";

It is possible also in the code of the report, i.e. in the BeforePrintEvent of the page.

Thank you.
james
Posts: 6
Joined: Tue May 05, 2009 4:08 am

image in web report

Post by james »

hi dear Edward . sorry for my delay.

i changed my code:
this.imgEmployee.ImageURLValue = "d:\abc.jpg";

it did not work, after that i changed my code again:
public void Page1_BeforePrint(object sender, System.EventArgs e)
{
this.imgEmployee.ImageURLValue = "d:\abc.jpg";
}
but StiWebViewer did not load image.

i changed Stimulsoft assembly to last version and test previous actions, but ...

i don't know what can i do to solve my problem!!

thanks
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

image in web report

Post by Edward »

Hi James,

Was the folder you tried to access accessible? Maybe the path was not correct?

Thank you.
james
Posts: 6
Joined: Tue May 05, 2009 4:08 am

image in web report

Post by james »

hi

the path is real and correct, i tested it:

this.imgEmployee.ImageURLValue = "~/img.jpg";
or
this.imgEmployee.ImageURLValue = "d:\img.jpg";

but i can not do that.:amazed:

by the way, i have Stimulsoft.Report 2007 and use it.
does it work well?

Thank you
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

image in web report

Post by Jan »

Hello,

Please add following method in your report code:

Code: Select all

public static Image LoadBitmap(string url)
{
	WebClient cl = new WebClient();
	cl.Credentials = CredentialCache.DefaultCredentials;
	byte [] bytes = cl.DownloadData(url);
        cl.Dispose();

	MemoryStream stream = new MemoryStream(bytes);
        return new Bitmap(stream);
}
Also you need add usings to:

Code: Select all

System.IO
System.Net
After then in BeforePrintEvent of image component:

Code: Select all

Image1.ImageToDraw = LoadBitmap("http://www.stimulsoft.com/Images/Logo/stimulsoft.logo.png");
Thank you.
Attachments
178.Sample.png
178.Sample.png (101.75 KiB) Viewed 3990 times
Post Reply