I am trying to render a report as an image in my web service and return a byte[] to my client. The byte[] is then converted back into an image for display in the browser. From my debug sessions, I can see that byte[] does have data in it and the view appears to have a correctly sized image; however, the image is completely blank.
This report in particular requires one Integer parameter, ArgID, to be passed in. Blank values can not be accepted. Below is the code I am using (function names and arguments have been modified for brevity).
Web-Service code to render the report as an image:
View file img tag:
Action called from img tag:
I've only just started using Telerik Reporting over SSRS and would like to make the case for switching to Telerik for a long-term solution if I can manage to get programmatic generation working within specifications. Any and all support is greatly appreciated.
Thank you,
-J
This report in particular requires one Integer parameter, ArgID, to be passed in. Blank values can not be accepted. Below is the code I am using (function names and arguments have been modified for brevity).
Web-Service code to render the report as an image:
public
byte
[] GetReport(
int
ArgID)
{
try
{
Telerik.Reporting.Processing.ReportProcessor proc =
new
Telerik.Reporting.Processing.ReportProcessor();
Telerik.Reporting.InstanceReportSource irs =
new
Telerik.Reporting.InstanceReportSource();
Report1 report =
new
Report1();
report.ReportParameters.Add(
new
Telerik.Reporting.ReportParameter(
"ArgID"
, Telerik.Reporting.ReportParameterType.Integer, ArgID));
irs.ReportDocument = report;
RenderingResult item = proc.RenderReport(
"IMAGE"
, irs,
null
);
return
item.DocumentBytes;
}
catch
(Exception ex)
{
throw
new
FaultException(
new
FaultReason(ex.ToString()));
}
}
View file img tag:
@model int
<
img
src
=
"@Url.Action("
GetReport", "Report", new {
ID
=
Model
})"
alt
=
""
/>
Action called from img tag:
[HttpGet]
public
ActionResult GetReport(
int
ID)
{
byte
[] img;
using
(var client =
new
MyService.MyServiceClient())
{
img = client.GetReport(ID);
}
return
File(img,
"image/tiff"
);
}
I've only just started using Telerik Reporting over SSRS and would like to make the case for switching to Telerik for a long-term solution if I can manage to get programmatic generation working within specifications. Any and all support is greatly appreciated.
Thank you,
-J