Exporting a report to PDF programmatically
Environment
Product | Progress® Telerik® Reporting |
Description
This article explains how to export a report to PDF without the need to go through a report viewer.
Solution
For ASP.NET Framework
You can use the following code snippet to programmatically export the report into PDF
format from a Web Site or Web Application project:
For ASP.NET Core
In ASP.NET Core, the Response
object does not expose a BinaryWrite
method. For that reason, the approach will need to change a little.
We can instead use the document bytes of the result object returned by the RenderReport
method to return a FileContentResult:
Then, we can make an AJAX request to our controller method to get the rendered report and return it as an attachment using Blobs.
Notes
Whether the report will be downloaded or previewed in the browser depends on the browser's PDF document settings, for example: