I have an application where I have to print a RDLC
report without showing the printDialog and using the default specified printer defined in the application. Be
i have made an extension class to @tezzos answer. which might make it more easier.
use this Gist Here to get the extension class i wrote. include it to your project. don't for get namespace :D
LocalReport report = new LocalReport();
report.ReportEmbeddedResource = "Your.Reports.Path.rdlc";
report.DataSources.Add(new ReportDataSource("DataSet1", getYourDatasource()));
report.PrintToPrinter();
PrintToPrinter
Method will be available on LocalReport
. Might Help someone
public void PrintSales(object sender, RenderingCompleteEventArgs e)
{
try
{
reportViewerSales.PageSetupDailog();
reportViewerSales.PrintDialog();
reportViewerSales.Clear();
reportViewerSales.LocalReport.ReleaseSandboxAppDomain();
}
catch (Exception ex)
{
}
}
I just gave a quick look to a class I created to print directly and I think I took some ideas from this walkthrough: Printing a Local Report without Preview