Introduction

In my previous article I described how to create a RDLC report.

Now I show how to save a RDLC report as a PDF at run time.

I am creating a method for that named "SAVEPDF" with the two arguments:

Here is the sample code:

  1. public void SavePDF(ReportViewer viewer, string savePath)
  2. {
  3. byte[] Bytes = viewer.LocalReport.Render(format:"PDF",deviceInfo:"");
  4. using (FileStream stream = new FileStream(savePath, FileMode.Create))
  5. {
  6. stream.Write(Bytes, 0, Bytes.Length);
  7. }
  8. }


We can save the RDLC report in another format like Word or Excel; not just in PDF.