'How can I pass a parameter to PDF rendering in ActiveReports 14?
I am implementing a .Net Core 3.1 REST API that needs to generate a PDF file for a given contract (the contract ID is known).
I have adopted the following code in ActiveReports 14 documentation to generate a sample report without any dynamic data in the API, and it is working fine:
// Provide the page report you want to render.
System.IO.FileInfo rptPath = new System.IO.FileInfo(@"..\..\PageReport1.rdlx");
GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport(rptPath);
// Create an output directory.
System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyPDF");
outputDirectory.Create();
// Provide settings for your rendering output.
GrapeCity.ActiveReports.Export.Pdf.Page.Settings pdfSetting = new GrapeCity.ActiveReports.Export.Pdf.Page.Settings();
// Set the rendering extension and render the report.
GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension pdfRenderingExtension = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory,
System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name));
// Overwrite output file if it already exists
outputProvider.OverwriteOutputFile = true;
pageReport.Document.Render(pdfRenderingExtension, outputProvider, pdfSetting);
However, now I need to modify the report to contain the dynamic data. The dynamic data is selected based on the contract ID. I think I can manage to create the necessary data source(s) (SQL) and dataset(s), but first I need to figure it out, how the contract ID should be passed for data sources/datasets to return the correct data.
Any advice?
Solution 1:[1]
You can add parameters from Active reports designer and set their properties according to your requirement. It will fetch data on the base of parameters passed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Zoraiz Hammad |