Generate PDF from Asp.Net Core

4 posts, 0 answers
  1. Henrique Duarte
    Henrique Duarte avatar
    105 posts
    Member since:
    Oct 2003

    Posted 30 Jan Link to this post

    How can I generate PDF from a .Net Core WebApplication?
    I'm using the following code:

    var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
    var uriReportSource = new Telerik.Reporting.UriReportSource();
     
    uriReportSource.Uri = "Report.tdrp";
     
    var result = reportProcessor.RenderReport("PDF", uriReportSource, null);
     
    var output =  result.DocumentBytes;
     
    return File(output, "application/pdf");

     

    But it gives me an exception:

    System.BadImageFormatException: Could not load file or assembly 'System.Windows.Forms'

  2. Silviya
    Admin
    Silviya avatar
    414 posts

    Posted 01 Feb Link to this post

    Hi Henrique,

    From my understanding you want to export the report in PDF format programmatically (without using the report viewer) from a .NET Core application.
    In general, t
    o export a report, you can use the RenderReport method of the ReportProcessor class. This method converts the contents of the report to a byte array in the specified format, which you can then use with other classes such as MemoryStream or FileStream. For more information, please refer to Exporting a report to a single document format help article.

    As of R1 2019, Telerik Reporting engine can be integrated in pure .NET Core projects - .NET Core Support.

    Regards,
    Silviya
    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
  3. Hossein
    Hossein avatar
    7 posts
    Member since:
    Jan 2012

    Posted 21 Aug in reply to Silviya Link to this post

    Hi Silviya

    Can you please provide a sample code for Rendering a Report as PDF problematically ?  (for Asp.Net Core) 

     

  4. Silviya
    Admin
    Silviya avatar
    414 posts

    Posted 26 Aug Link to this post

    Hi Hossein,

    The previously linked article contains a code snippet how to export reports programmatically - Embedded Report Engine. You can create a method in your application which will produce the PDF document.

    Best Regards,
    Silviya
    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