How to print the report silently without preview the report in Report Viewer

To print a report silently in a WPF application without previewing it in the Report Viewer, use the Bold Reports® Report Writer to export the report to a PDF stream and the PdfDocumentView to print it. Follow these steps to print the report silently.

Initialize the Report Writer with reports and data sources, and use the Save API to get the printable PDF in a stream.

string reportPath = @"../../ReportTemplate/Product Details.rdlc";
ReportWriter reportWriter = new ReportWriter(reportPath);
reportWriter.ReportProcessingMode = ProcessingMode.Local;
reportWriter.DataSources.Clear();
reportWriter.DataSources.Add(new ReportDataSource { Name = "DataSet1", Value = ProductCatalog.GetData() });
MemoryStream stream = new MemoryStream();
reportWriter.Save(stream, WriterFormat.PDF);

Load the exported stream into the PdfDocumentView using the PdfDocumentView.Load API and add the available printers to a list for printing the report using the Windows PrintDialog as shown in the following code example:

PdfDocumentView pdfdoc = new PdfDocumentView();
pdfdoc.Load(stream);
var doc = pdfdoc.PrintDocument as IDocumentPaginatorSource;
PrintDialog printDialog = new PrintDialog();
List<string> printersList = new List<string>();
List<string> serversList = new List<string>();
var server = new PrintServer();
var queues = server.GetPrintQueues(new[] { EnumeratedPrintQueueTypes.Local });
foreach (var queue in queues)
{
 if (!serversList.Contains(queue.HostingPrintServer.Name))
 {
  serversList.Add(queue.HostingPrintServer.Name);
 }
 printersList.Add(queue.FullName);
}
server = new PrintServer(serversList[0].ToString());
PrintQueue printer1 = server.GetPrintQueue(printersList[2].ToString());
printDialog.PrintQueue = printer1;
printDialog.PrintDocument(doc.DocumentPaginator, "PDF PRINTER");