ASP.NET - Print option in Rdlc

Asked By Jain on 06-Jan-11 03:41 AM
how to place direct print option in rdlc?
thank you......
Anoop S replied to Jain on 06-Jan-11 04:12 AM
You can render the report out by declaring an instance of the report viewer and the calling render method (see below)

Dim viewer As New Microsoft.Reporting.WebForms.ReportViewer
Dim sqlReport As Byte()
Dim outMimeType As String = ""
Dim outEncoding As String = ""
Dim outFileExtension As String = ""
Dim outDeviceInfo As String = ""       
Dim streamids As String()
Dim warnings As Microsoft.Reporting.WebForms.Warning()
 
viewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local
viewer.LocalReport.ReportEmbeddedResource = "MyProjectRootNamespace.MyReport.rdlc"
sqlReport = viewer.LocalReport.Render(format, outDeviceInfo, outMimeType, outEncoding, outFileExtension, streamids, warnings)
Reena Jain replied to Jain on 06-Jan-11 04:44 AM
hi,

here is the code for you
private void Print()
  {
    const string printerName =
       "Microsoft Office Document Image Writer";
    if (m_streams == null || m_streams.Count == 0)
      return;
    PrintDocument printDoc = new PrintDocument();
    printDoc.PrinterSettings.PrinterName = printerName;
    if (!printDoc.PrinterSettings.IsValid)
    {
      string msg = String.Format(
         "Can't find printer \"{0}\".", printerName);
      MessageBox.Show(msg, "Print Error");
      return;
    }
    printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
    printDoc.Print();
  }

hope this will help you