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
If you became a customer of the Syncfusion Reporting Platform or the Report Viewer, Report Designer, or Report Writer components before October 2019 and have questions related to those products, you can request support through our forum system. However, please note that this support system is only for existing customers who are still using the Syncfusion Reporting Platform or its components and not for new customers looking for reporting products from Syncfusion.

For new customers or those with general reporting questions, we recommend contacting our support team at https://support.boldreports.com/, which is a separate brand created by Syncfusion for its reporting solutions. Our team will be happy to assist you with any questions you may have.

Thank you for choosing Syncfusion for your reporting needs.

Webservice that creates report and returns as it PDF

Hello,

I have a webservice in ASP.Net and I need to return reports converted to PDF.
What I want :
- Manually Draw/Create a Report with a designer.
- Webservice creates report in memory, converts it to PDF and returns the PDF.

I don't need a reportviewer ! I only want to create reports in memory.
 
Is this possible and what version do I need to install ?


Regards,Gert

11 Replies

VS Vinoth Srinivasan Syncfusion Team September 12, 2017 11:39 AM UTC

Hi asterinex, 

Thanks for your interest in Syncfusion Components. 

Query 
Response 
Manually Draw/Create a Report with a designer. 
Please find the report designer sample to create a report. 


Please refer the below UG documentation for more details, 

You can obtain the WPF report designer samples from the below build installed location, 
%userprofile%\AppData\Local\Syncfusion\EssentialStudio\version\WPF\Reports.WPF\Samples\ReportDesigner.WPF 
Webservice creates report in memory, converts it to PDF and returns the PDF.

I don't need a reportviewer ! I only want to create reports in memory.
 
 
We can achieve your requirement by using ReportWriter control to export the report into PDF, Excel, Word, PPT and HTML directly without displaying in WebAPI controller and return the result as per your request as shown in below code example. 

        protected void ExportButton_Click(object sender, EventArgs e) 
        { 
            try 
            { 
                string fileName = null; 
                WriterFormat format;                
                HttpContext httpContext = System.Web.HttpContext.Current; 
                ReportWriter reportWriter = new ReportWriter(); 
                reportWriter.ReportPath = Server.MapPath("~/App_Data/GroupingAgg.rdl");                 
                reportWriter.ReportProcessingMode = ProcessingMode.Remote; 
 
                if (this.ExportFormat.SelectedValue == "PDF") 
                { 
                    fileName = "GroupingAgg.pdf"; 
                    format = WriterFormat.PDF; 
                } 
                else if (this.ExportFormat.SelectedValue == "Word") 
                { 
                    fileName = "GroupingAgg.doc"; 
                    format = WriterFormat.Word; 
                } 
                else if (this.ExportFormat.SelectedValue == "Html") 
                { 
                    fileName = "GroupingAgg.Html"; 
                    format = WriterFormat.HTML; 
                } 
                else 
                { 
                    fileName = "GroupingAgg.xls"; 
                    format = WriterFormat.Excel; 
                } 
                reportWriter.Save(fileName, format, httpContext.Response); 
            } 
            catch { } 
        } 

We have prepared a ReportWriter sample and it can have downloaded from, 

Please refer to the below UG documentation for more detail, 

You can obtain the ASP.Net ReportWriter samples from the below build installed location, 
%userprofile%\AppData\Local\Syncfusion\EssentialStudio\version\Web\Samples\Web 

Is this possible and what version do I need to install ? 
You can install our latest ASP.Net build to export the report using ReportWriter, it can be downloaded from below location. 


Regards, 
Vinoth S. 



AS asterinex September 12, 2017 01:34 PM UTC

Hi Vinoth,

thx for your extensive answer. Looks very promising.
So if I'm right, I need to use the WPF-Reportdesigner to create a report and save this as a

rdl-file.
Then I can use this RDL-File in my webservice to create a PDF with
the ReportWriter-Class ?

Is this summary correct ?



VS Vinoth Srinivasan Syncfusion Team September 13, 2017 10:59 AM UTC

Hi asterinex, 

Yes, you can create a RDL report using our WPF report designer and save the report to local folder. In your web service use the ReportWriter class to access the saved report and convert the report to PDF then return the stream to your client. 

Regards, 
Vinoth S. 



AS asterinex September 19, 2017 07:02 AM UTC

Hi Vinoth,

I managed to create an RDL Report, convert it to PDF and send the PDF with email to an emailadress in asp.net:)

But 2 things I could not figure out. In WPF I managed to do it, but not in ASP.NET
(See picture in attachement for more info)

1) How do I set reportparameters ? The method reportWriter.SetParameters(.....) takes a List of 'Syncfusion.Reports.EJ.Reportparameter'
    I cannot find this class. Do I miss Something ?
2) How do I change the connectstring for the database programmatically ?





Attachment: reportcode_7b8b5a4d.zip


YD Yuvaraj Devarajan Syncfusion Team September 20, 2017 04:59 AM UTC

Hi Asterinex, 

Thanks for the update. 

1) How do I set reportparameters ? The method reportWriter.SetParameters(.....) takes a List of 'Syncfusion.Reports.EJ.Reportparameter' 
    I cannot find this class. Do I miss Something ? 

We suspect the mentioned problem occurs when the “Syncfusion.EJ.ReportViewer” assembly is not referred properly in your application. If the mentioned issue is again reproduced after referring the Syncfusion assemblies, then it might occur when the Syncfusion namespace references is not added in web.config file in your application. So we request you to specify the “Syncfusion.JavaScript.Web” namespaces in web.config as shown in shared screenshot in your application to rectify the mentioned issue at your end.   

 

2) How do I change the connectstring for the database programmatically ? 

We have an option to change the connection string of the report using SetDataSourceCredentials method in ReportWriter as shown in below code example, 

            try 
            { 
                string fileName = null; 
                WriterFormat format;                
                HttpContext httpContext = System.Web.HttpContext.Current; 
                ReportWriter reportWriter = new ReportWriter(); 
                reportWriter.ReportPath = Server.MapPath("~/App_Data/GroupingAgg.rdl");                 
                reportWriter.ReportProcessingMode = ProcessingMode.Remote; 
 
                DataSourceCredentials _credential = new DataSourceCredentials(); 
                _credential.ConnectionString = "Data Source=mvc.syncfusion.com;Initial Catalog=AdventureWorks;"; 
                _credential.Name = "AdventureWorks"; //Datasource name 
                _credential.UserId = "ssrs1"; 
                _credential.Password = "RDLReport1"; 
 
                IList<DataSourceCredentials> _credentials = new List<DataSourceCredentials>(); 
                _credentials.Add(_credential); 
                reportWriter.SetDataSourceCredentials(_credentials); 
 
                List<ReportParameter> parameters = new List<ReportParameter>(); 
                parameters.Add(new ReportParameter() { Name = "ReportParameter1", Labels = new List<string>() { "SampleValue" }, Values = new List<string>() { "SampleValue" } }); 
                reportWriter.SetParameters(parameters); 
 
 
                if (this.ExportFormat.SelectedValue == "PDF") 
                { 
                    fileName = "GroupingAgg.pdf"; 
                    format = WriterFormat.PDF; 
                } 
                else if (this.ExportFormat.SelectedValue == "Word") 
                { 
                    fileName = "GroupingAgg.doc"; 
                    format = WriterFormat.Word; 
                } 
                else if (this.ExportFormat.SelectedValue == "Html") 
                { 
                    fileName = "GroupingAgg.Html"; 
                    format = WriterFormat.HTML; 
                } 
                else 
                { 
                    fileName = "GroupingAgg.xls"; 
                    format = WriterFormat.Excel; 
                } 
                reportWriter.Save(fileName, format, httpContext.Response); 
            } 
            catch { } 
        } 

We have prepared a sample and it can be downloaded from below location, 



Regards, 
Yuvaraj D. 



AS asterinex September 27, 2017 05:34 PM UTC

thx Vinoth for the samples. Everythings works like a charm now. Very good software :) !

I have one quesytion, but is not urgent.

What is the difference between properties ReportParameters.Labels and
ReportParameters.Values ?

    




YD Yuvaraj Devarajan Syncfusion Team September 28, 2017 02:35 PM UTC

Hi Asterinex, 

Thanks for the update. 

Report Parameter Label 
Report Parameter Value 
Labels will be displayed in the parameter instead of parameter values. You can display meaningful user-friendly labels in the parameter instead of actual value. 

For example: If you want to show the user "ProductName" but use "ProductID" as the value of the parameter. 

Value doesn’t display in the Parameter, it can be used within the report or expression. 

For example:  if you have to specify a "value field" for parameter, in case you want the user to be prompted with something meaningful to them then use labels.  

Regards, 
Yuvaraj D. 



AS asterinex December 18, 2017 10:36 AM UTC

Dear Syncfusion,

is it possible to add a watermarkt and preferably programmatically ?
like 'reportWriter.Watermark = "Test";' 


regards,Gert


YD Yuvaraj Devarajan Syncfusion Team December 19, 2017 11:54 AM UTC

Hi Gert, 
 
We can design the report (RDL/RDLC) with background image for the body report item as watermark. Since, we don’t have option to set the water mark text in report as per RDL standard. But, we can able to achieve this using “set background image” property for body report item as shown in below screenshot. 
 
 
 
Note: For the watermark we should use the low opacity background image for the body property. 
 
Please refer to the below MSDN documentation for more information, 
 
Regards, 
Yuvaraj D. 



AS asterinex December 19, 2017 03:52 PM UTC

Thx Yuvaraj,

is it possible to set this by code (reportwrite) ?
I need different watermarks for the same report (Test, Duplicate, ... )


YD Yuvaraj Devarajan Syncfusion Team December 20, 2017 01:30 PM UTC

Hi Glenn, 

We have an issue while export the report with body background image and logged a defect report on this. So a support incident to track the status of this future has been created under your account. Please log on to our support website to check for further updates.
https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Regards, 
Yuvaraj D. 


Loader.
Live Chat Icon For mobile
Up arrow icon