How to load an image dynamically to a report JS?

Stimulsoft Reports.JS discussion
Post Reply
ruchira
Posts: 4
Joined: Fri Jun 09, 2017 11:50 am

How to load an image dynamically to a report JS?

Post by ruchira » Tue Jul 11, 2017 10:04 am

I want dynamically load an image to report. I'm using stimulsoft report js viewer and i found below code available for Stimulsoft Reports.Wpf

Code: Select all

StiReport report = new StiReport();
report.Load("e:\\Report.mrt");
StiImage stiImage = report.GetComponents()["Image1"] as StiImage;
Image myImage = Image.FromFile(@"e:\Image.jpg");
stiImage.Image = myImage;
report.Show();
Please help me to convert this to JS version
Thanks
Ehsan
Posts: 97
Joined: Tue Jan 05, 2016 10:39 am
Location: Iran

Re: How to load an image dynamically to a report JS?

Post by Ehsan » Wed Jul 12, 2017 10:24 am

Hello
you can use below code:


Code: Select all

//Create image on Header
var sampleImage = new Stimulsoft.Report.Components.StiImage();

var stiImage = Stimulsoft.System.Drawing.Image.fromFile(your file);
stiImage.aspectRatio = true;

sampleImage.image = stiImage;

sampleImage.width = 10;
sampleImage.height = 10;
sampleImage.stretch = true
sampleImage.aspectRatio = true;

ReportTitleBand.components.add(sampleImage);
Alex K.
Posts: 6489
Joined: Thu Jul 29, 2010 2:37 am

Re: How to load an image dynamically to a report JS?

Post by Alex K. » Thu Jul 13, 2017 8:50 pm

Hello,

Thank you for your solution.
ruchira
Posts: 4
Joined: Fri Jun 09, 2017 11:50 am

Re: How to load an image dynamically to a report JS?

Post by ruchira » Mon Jul 24, 2017 6:38 am

Thanks Ehsan for your solution and i used resource component to do this as follows

Code: Select all

var report = new Stimulsoft.Report.StiReport();
report.loadFile("reports/SimpleList.mrt");
var content = Stimulsoft.System.IO.Http.getFile("https://xxxx.blob.core.windows.net/Screenshot%20(37).jpg", true);
var resource = new Stimulsoft.Report.Dictionary.StiResource("Resource1", "Resource1", false, Stimulsoft.Report.Dictionary.StiResourceType.Image, content);
report.dictionary.resources.add(resource);
HighAley
Posts: 8065
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: How to load an image dynamically to a report JS?

Post by HighAley » Mon Jul 24, 2017 11:16 am

Hello.

This code adds a resource to the report.
You could use it in your report.

Thank you.
iphayc
Posts: 1
Joined: Thu Nov 09, 2017 1:26 am

Re: How to load an image dynamically to a report JS?

Post by iphayc » Thu Nov 09, 2017 1:40 am

ruchira wrote:I want dynamically load an image to report. I'm using stimulsoft report js viewer and i found below code available for Stimulsoft Reports.Wpf

Code: Select all

StiReport report = new StiReport();
report.Load("e:\\Report.mrt");
StiImage stiImage = report.GetComponents()["Image1"] as StiImage;
Image myImage = Image.FromFile(@"e:\Image.jpg");
stiImage.Image = myImage;
report.Show();
Please help me to convert this to JS version
Thanks
Hi,

try this code :

Code: Select all

var report = new Stimulsoft.Report.StiReport();
		report.loadFile("e:/report.mrt");
               //create variable image and loadfile from local disk ex. location image on drive c:/
		var stiImage = Stimulsoft.System.Drawing.Image.fromFile("c:/image.jpg");		
		
               //create variable with type : image, create that variable on the report with name : var_image
		var var1 = report.dictionary.variables.getByName("var_image");	
		var1.valueObject = stiImage;		
		viewer.report = report;
		viewer.renderHtml("viewerContent");
thanks,
Ipay
Andrew
Posts: 3867
Joined: Fri Jun 09, 2006 3:58 am

Re: How to load an image dynamically to a report JS?

Post by Andrew » Sun Nov 12, 2017 4:39 pm

ruchira,

Does the code offered by iphayc helped you?

Thank you.
Post Reply