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:
- Path (Location) as string type where we want to save that PDF file.
Example: C:\MyFile\
- Another is ReportViewer that is the instance of the ReportViewer Class
On which we will perform the action to convert the report to a PDF; but not just PDF, we can save the file in another format, such as Word or Excel.
Here is the sample code:
- public void SavePDF(ReportViewer viewer, string savePath)
- {
- byte[] Bytes = viewer.LocalReport.Render(format:"PDF",deviceInfo:"");
- using (FileStream stream = new FileStream(savePath, FileMode.Create))
- {
- stream.Write(Bytes, 0, Bytes.Length);
- }
- }
We can save the RDLC report in another format like Word or Excel; not just in PDF.

Larry RousePosted Jul 7, 2019, 7:26 AM
This is brilliant! Works like a charm and solved a major problem for me. Thanks
Luai MaanePosted Nov 27, 2018, 7:40 AM
Dear can i print the rendering PDF direct without saving on drive ,if yes please the code .
Daniel PickerPosted Feb 7, 2018, 8:22 AM
Hello ck! I have this issue : An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dllAccess to the path'D:\Aqueduc\RapportsAqueduc' is denied. You have an idea?
stylesmylez smylezPosted Jan 24, 2018, 7:38 PM
This is awsome!!!!!!!!!!!!!!!!!!
Jyoti JodhaPosted Jun 20, 2017, 7:28 AM
Hello Sir,Can we set font color , Back color, Left Margin,Right Margin,Top Margin,Bottom margin,Logo etc to ssrs local report from c#
karthi pmPosted Mar 27, 2015, 9:59 AM
this is not working waste of time
shiju kvPosted Jan 7, 2015, 11:21 PM
it shows an exception the sourse is not defined.what is the device info
Freddy CorleonPosted Nov 21, 2014, 12:14 PM
How to save as Word and call from page load?