Click here to Skip to main content
15,887,240 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I have created PDF from RDLC report in consol application.

same thing I wanna to create PDF file from RDLC report in RestWcf Service.
I will create one restful wcf service and I should be able to call that service, and that service should created one PDF file by using RDLC report (ReportViewer) and will return that created PDF file.

How can I achieve this?

Please help me out..

Thank You in advance.............
Posted
Updated 22-May-13 21:36pm
v2

1 solution

You can easily create a PDF output of your RDLC report by using the code. You get the PDF in a buffer (array of bytes) that can return from your service.

C#
//create PDF version of RDLC report
LocalReport myReport = new LocalReport();
myReport.ReportPath = "MyReport.rdlc";
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("~/NorthwindProducts.xml"));
myReport.DataSources.Add(new ReportDataSource("Products", ds.Tables[0]));

//Export to PDF. Get binary content.
string mimeType;
string encoding;
string fileNameExtension;
string[] streams;
Warning[] warnings;

byte[] pdfContent = myReport.Render("PDF", null, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900