I have a Telerik Reporting Library 2019 project which contains Telerik Reports. The reports are consumed from a ASP.NET Core web application when controller actions are called. So there is a reference to this Reporting library project from Web project.
In the web project I create a ReportBook to generate report. and render the report as a PDF.
[HttpGet(
"{reportId}"
, Name =
"Report"
)]
public
async Task<IActionResult> Get(Guid reportId)
{
//Report Book
var reportBook =
new
ReportBook();
var instanceReportBookSource =
new
InstanceReportSource
{
ReportDocument = reportBook
};
//Cover Page
var coverPageReportSource =
new
InstanceReportSource();
var coverPagereport =
new
CoverPage(reportId)
{
DocumentName =
"Cover Page Report"
};
coverPageReportSource.ReportDocument = coverPagereport;
reportBook.ReportSources.Add(coverPageReportSource);
var reportProcessor =
new
ReportProcessor();
var renderingResult = reportProcessor.RenderReport(
"PDF"
, instanceReportBookSource,
new
Hashtable());
var fileName = renderingResult.DocumentName +
"."
+ renderingResult.Extension;
var path = Path.GetTempPath();
var filePath = Path.Combine(path, fileName);
using
(var fs =
new
FileStream(filePath, FileMode.Create))
{
fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length);
}
var output = renderingResult.DocumentBytes;
return
File(output,
"application/pdf"
);
}
In the reports I have few PictureBox components. I want to set pictures from a http url (https://docs.telerik.com/reporting/report-items-picture-box#data-binding)
Example
1.
var pictureBox = ((Telerik.Reporting.PictureBox)(reportDef.Items.Find(
"pictureBox1"
,
true
)[0]));
2.
pictureBox.Value =
"https://d585tldpucyb98b4-413e94c0e92bvanemkallan.jpg"
; //Some Image URL
But when I try to do that it always gives an error (report-error.png). Is this because I have report definition in one project and consuming it from another project (web project). How can I solve this.