title: print RDLC reports in c#
body: <p>In following code it gives me an error here, i dont have an idea what am i missing here. 
  Error: 
   An unhandled exception of type   'Microsoft.Reporting.WinForms.LocalProcessingException' occurred in   Microsoft.ReportViewer.WinForms.dll Additional information: An error occurred during local report processing.
      Here is my code:</p>
  
  <pre><code>using Microsoft.Reporting.WinForms;
  using Microsoft.Reporting.WinForms.Internal.Soap.ReportingServices2005.Execution;
  using System;
  using System.Collections.Generic;
  using System.Data;
  using System.Drawing;
  using System.Drawing.Imaging;
  using System.Drawing.Printing;
  using System.IO;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  
     namespace WindowsFormsApplication1
       {   
       public class Printanje : IDisposable
     {
      private int m_currentPageIndex;
      private IList&lt;Stream&gt; m_streams;
  
      public DataTable LoadSalesData()
      {
          // Create a new DataSet and read sales data file 
          //    data.xml into the first DataTable.
          DataSet dataSet = new DataSet();
          dataSet.ReadXml(@"..\..\ivana1.xml");
          return dataSet.Tables["DataTable1"];
      }
      // Routine to provide to the report renderer, in order to
      //    save an image for each page of the report.
      public Stream CreateStream(string name,
        string fileNameExtension, Encoding encoding,
        string mimeType, bool willSeek)
      {
          Stream stream = new MemoryStream();
          m_streams.Add(stream);
          return stream;
      }
      // Export the given report as an EMF (Enhanced Metafile) file.
      public 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.25in&lt;/MarginTop&gt;
                  &lt;MarginLeft&gt;0.25in&lt;/MarginLeft&gt;
                  &lt;MarginRight&gt;0.25in&lt;/MarginRight&gt;
                  &lt;MarginBottom&gt;0.25in&lt;/MarginBottom&gt;
              &lt;/DeviceInfo&gt;";
          Microsoft.Reporting.WinForms.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;
      }
      // Handler for PrintPageEvents
      public void PrintPage(object sender, PrintPageEventArgs ev)
      {
          Metafile pageImage = new
             Metafile(m_streams[m_currentPageIndex]);
  
          // Adjust rectangular area with printer margins.
          Rectangle adjustedRect = new Rectangle(
              ev.PageBounds.Left - (int)ev.PageSettings.HardMarginX,
              ev.PageBounds.Top - (int)ev.PageSettings.HardMarginY,
              ev.PageBounds.Width,
              ev.PageBounds.Height);
  
          // Draw a white background for the report
          ev.Graphics.FillRectangle(Brushes.White, adjustedRect);
  
          // Draw the report content
          ev.Graphics.DrawImage(pageImage, adjustedRect);
  
          // Prepare for the next page. Make sure we haven't hit the end.
          m_currentPageIndex++;
          ev.HasMorePages = (m_currentPageIndex &lt; m_streams.Count);
      }
  
      public void Print()
      {
          if (m_streams == null || m_streams.Count == 0)
              throw new Exception("Error: no stream to print.");
          PrintDocument printDoc = new PrintDocument();
          if (!printDoc.PrinterSettings.IsValid)
          {
              throw new Exception("Error: cannot find the default printer.");
          }
          else
          {
              printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
              m_currentPageIndex = 0;
              printDoc.Print();
          }
      }
      // Create a local report for Report.rdlc, load the data,
      //    export the report to an .emf file, and print it.
      public void Run()
      {
          LocalReport report = new LocalReport();
          report.ReportPath = @"C:\Users\user\Desktop\Report.rdlc";
          report.DataSources.Add(
             new ReportDataSource("Raboti", LoadSalesData()));
          Export(report);
          Print();
      }
  
      public void Dispose()
      {
          if (m_streams != null)
          {
              foreach (Stream stream in m_streams)
                  stream.Close();
              m_streams = null;
          }
      }
  
  
  
          }
       }
   //and in my form1 im calling:
  
           private void button1_Click(object sender, EventArgs e)
              {
              using (Printanje demo = new Printanje())
              {
                  demo.Run();
              }
  
          }
  </code></pre>