title: Print RDLC Report in ASP.net without preview on Client Side
body: <p>I have a RDLC report that prints fine locally when is run in Visual Studio. When I upload
  my project to the server it wont print. I was doing some research and learned that when the project is in the server it tries to print on the server, not in the client machine. Does anybody now how to print to the client machine?</p>
  
  <pre><code>   private Stream CreateStream(string name, string fileNameExtension, Encoding encoding,         string mimeType, bool willSeek)
      {
          Stream stream = new MemoryStream();
          m_streams.Add(stream);
          return stream;
      }
  
      private void Export(LocalReport report)
      {
          string deviceInfo =
            "&lt;DeviceInfo&gt;" +
            "  &lt;OutputFormat&gt;EMF&lt;/OutputFormat&gt;" +
            "  &lt;PageWidth&gt;8.5in&lt;/PageWidth&gt;" +
            "  &lt;PageHeight&gt;11in&lt;/PageHeight&gt;" +
            "  &lt;MarginTop&gt;0.01in&lt;/MarginTop&gt;" +
            "  &lt;MarginLeft&gt;0.02in&lt;/MarginLeft&gt;" +
            "  &lt;MarginRight&gt;0.25in&lt;/MarginRight&gt;" +
            "  &lt;MarginBottom&gt;0.25in&lt;/MarginBottom&gt;" +
            "&lt;/DeviceInfo&gt;";
          Warning[] warnings;
          m_streams = new List&lt;Stream&gt;();
          report.Render("Image", deviceInfo, CreateStream, out warnings);
          foreach (Stream stream in m_streams)
          {
              stream.Position = 0;
          }
      }
      private void PrintPage(object sender, PrintPageEventArgs ev)
      {
          Metafile pageImage = new Metafile(m_streams[currentPageIndex]);
          ev.Graphics.DrawImage(pageImage,ev.PageBounds);
          currentPageIndex++;
          ev.HasMorePages = (currentPageIndex &lt; m_streams.Count);
      }
  
  
      private void Print_Ticket()
      {
  
          const string printerName = "HP DeskJet";
          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);
              Console.WriteLine(msg);
              return;
          }
          printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
          printDoc.Print(); //Prints Document
      }
      public void WriteTicket(string ticket_number, string queue)
      {
          LocalReport report = new LocalReport();
          //Displays ticket letter and number in ticket
          report.ReportPath = "PrintTicket.rdlc";
          ReportParameter ticket_parameter = new ReportParameter();
          ticket_parameter.Name = "Ticket";
          ticket_parameter.Values.Add(ticket_number);
          report.SetParameters(new ReportParameter[] { ticket_parameter });
  
          //Displays date and time in ticket
          ReportParameter date = new ReportParameter();
          date.Name = "Date_Time";
          date.Values.Add(System.DateTime.Now.ToString());
          report.SetParameters(new ReportParameter[] { date });
  
          //Displays branch location in ticket
          ReportParameter location_parameter = new ReportParameter();
          location_parameter.Name = "Location";
          location_parameter.Values.Add(queue);
          report.SetParameters(new ReportParameter[] { location_parameter });
  
          Export(report);
          currentPageIndex = 0;
          Print_Ticket();
      }
      //Clears stream
      public new void Dispose()
      {
          if (m_streams != null)
          {
              foreach (Stream stream in m_streams)
                  stream.Close();
          }
      }
  </code></pre>