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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Direct PDF generation, without showing the report view

Thread ID:

Created:

Updated:

Platform:

Replies:

120178 Sep 8,2015 09:36 AM UTC Jul 4,2016 08:48 AM UTC JavaScript 5
loading
Tags: ejReportViewer
Nebojsa Zecevic
Asked On September 8, 2015 09:36 AM UTC

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

Soundara Rajan S [Syncfusion]
Replied On 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.

Nebojsa Zecevic
Replied On September 9, 2015 01:14 PM UTC

It works, thanks!

Soundara Rajan S [Syncfusion]
Replied On 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.

Jaume
Replied On 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.

Yuvaraj Devarajan [Syncfusion]
Replied On 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.  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;