Picturebox with Image url not working in multiple projects

3 posts, 0 answers
  1. Hari
    Hari avatar
    5 posts
    Member since:
    Mar 2019

    Posted 02 May 2019 Link to this post

    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;
        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)


    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.




  2. Hari
    Hari avatar
    5 posts
    Member since:
    Mar 2019

    Posted 02 May 2019 in reply to Hari Link to this post

    Error comes when rendering
  3. Todor
    Todor avatar
    488 posts

    Posted 07 May 2019 Link to this post

    Hello Hari,

    Such an error will appear when there is no value set to the PictureBox item (note that the value is an empty string "").
    From the provided information I assume that in the report definition pictureBox1 has no default value, and the image URL is set to the item definition (i.e. Telerik.Reporting.PictureBox) in the code.
    When this is done in the constructor of the report, right after the call to InitializeComponent() method the value should be respected and the image should be displayed.
    If this is done in a Report event it may not work, as it may be too late. I tested locally, and the code for setting the PictureBox image worked when used in the ItemDataBinding and NeedDataSource events of the Report, and threw the same error message when used in the ItemDataBound event (this is the last report event that is raised).
    For more details you may check the Changes on items in report events are not applied KB article.

    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top