We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon
Starting in 2019, the Reporting control is no longer included in Essential Studio. If you're experiencing issues with the Syncfusion Reporting Platform, Report Viewer, Report Designer, or Report Writer, we recommend migrating to Bold Reports, our dedicated reporting platform.

Bold Reports offers a comprehensive suite of tools and features for all your reporting needs, and we will help you make a smooth transition from the discontinued control. Our support team at https://support.boldreports.com/ is here to assist you with any questions or difficulties you may encounter during the migration process.

We thank you for choosing Syncfusion and appreciate your understanding.

Direct PDF generation, without showing the report view

Hi,

I have implemented ejReportViewer into my app using RDLC on the server side, and data for RDLC is prepared on client side. And everything is working fine, report is generated and data is bind.

Now I came to requirement where i have to save PDF from ejReportViewer to DB, or some other server. Is it possible to use server side to directly generate PDF without client side ejReportViewer control?

What I have in mind is that on server side i have function where i send JSON data that should represent data source for RDLC, then function will parse report and export PDF. So on client side i get PDF (not report). So i can save this PDF somewhere else.

I saw that there is an ReportHelper, and ReportHelper.ProcessReport that are responsible for report parsing. Is there an option to export PDF with this class?

Kind Regards,
Nebojsa Zecevic

5 Replies

SR Soundara Rajan S Syncfusion Team September 9, 2015 06:37 AM UTC

Hi Nebojsa,

Thanks for contacting Syncfusion Support.

We have option to export reports using our ReportWriter without rendering report in EJ ReportViewer control as shown in the below example,

HTML,

<form action="/api/ReportApi/ExportAction" method="post">

<input type="hidden" name="exporttype" value="PDF"/>

<input type="submit" value="Export"/>
</form>


WebAPI

public HttpResponseMessage ExportAction()

{

HttpResponseMessage _response = new HttpResponseMessage();


string writerFormat = HttpContext.Current.Request.Form["exporttype"];

string fileName = null;

WriterFormat format;

HttpContext httpContext = System.Web.HttpContext.Current;

ReportWriter reportWriter = new ReportWriter(httpContext.Server.MapPath("~/ReportTemplate/drilldown.rdlc"));

reportWriter.ReportProcessingMode = Syncfusion.EJ.ReportWriter.ProcessingMode.Local;


ReportDataSourceCollection dataSources = new ReportDataSourceCollection();

dataSources.Add(new ReportDataSource { Name = "Customers", Value = Customers.GetData() });


reportWriter.DataSources = dataSources;

fileName = "drilldown.pdf";

format = WriterFormat.PDF;

reportWriter.Save(fileName, format, httpContext.Response);

_response.StatusCode = System.Net.HttpStatusCode.OK;

return _response;

}

}


We have prepared a sample based on your request and it can be downloaded from the below location,
http://www.syncfusion.com/downloads/support/forum/120178/WriterDemo-856455847.zip

Regards,
Soundara Rajan S.


NZ Nebojsa Zecevic September 9, 2015 01:14 PM UTC

It works, thanks!


SR Soundara Rajan S Syncfusion Team September 10, 2015 04:02 AM UTC

Hi Nebojsa,

Thanks for the update. Please let us know, if you need any further assistance.

Regards,
Soundara Rajan S.


JA Jaume July 2, 2016 06:55 PM UTC

Hello,

i would like to know if I can do the same but passing some datasources from the client side, as in the "Control Creation" example from javascript where you pass the Datasource as a Json array.

Can I add an input and get it in the server side?

Thank you.


YD Yuvaraj Devarajan Syncfusion Team July 4, 2016 08:48 AM UTC

Hi Jaume, 

i would like to know if I can do the same but passing some datasources from the client side, as in the "Control Creation" example from javascript where you pass the Datasource as a Json array. 

We have an API to pass the JSON data at client side in our ReportViewer control as shown in the below code example.   
JS: 
     <script type="text/javascript"> 
            $(function () { 
                $("#container").ejReportViewer( 
                    { 
                        reportServiceUrl: "/api/ReportApi",                        
                        processingMode: ej.ReportViewer.ProcessingMode.Local,                        
                        reportPath: "~/Report/Sample.rdlc", 
                        dataSources: [{ 
                            value: [ 
                                { 
                                    AddressID: 1, 
                                    City: "Tokyo", 
                                    StateProvinceID: 101 
                                }, 
                                 { 
                                     AddressID: 2, 
                                     City: "NewYork", 
                                     StateProvinceID: 102 
                                 }, 
                                  { 
                                      AddressID: 3, 
                                      City: "Mumbai", 
                                      StateProvinceID: 103 
                                  }, 
                                   { 
                                       AddressID: 4, 
                                       City: "Paris", 
                                       StateProvinceID: 104 
                                   }, 
                                    { 
                                        AddressID: 5, 
                                        City: "Munich", 
                                        StateProvinceID: 105 
                                    }, 
                            ], 
                            name: "DataSet2" 
                        }] 
                    }); 
            }); 
    </script> 

We have prepared the sample using DataSource value from client side and it can be downloaded from the below location,   
 
Pleases refer to the below UG documentation for more detail, 
 
You can obtain the JavaScript ReportViewer samples from the below build installed location, 
%userprofile%\AppData\Local\Syncfusion\EssentialStudio\version\JavaScript\reportsamples 
 
Note: ReportWriter is a server side component and we could not initialize the ReportWriter control on client side.     
Can I add an input and get it in the server side? 
We can also pass the DataSource in server side (WebAPI) as shown in the below code example,   
 
WebAPI: 
public void OnReportLoaded(ReportViewerOptions reportOption) 
        { 
            reportOption.ReportModel.DataSources.Clear(); 
            reportOption.ReportModel.DataSources.Add(new ReportDataSource { Name = "DataSet2", Value = Dataset.GetData() }); 
        }       
 
We have prepared a sample using DataSource value from server side and it can be downloaded from the below location,   


Regards, 
Yuvaraj D.  


Loader.
Live Chat Icon For mobile
Up arrow icon