title: C# RDLC Report - Directly to Printer - Format Collapses
body: <p>I am using a ssrs client rdlc report (3-inch printer) in our WPF application.
  when the report rendered to.PDF and save it to a temporary path, and then prints the PDF means it works perfectly. 
  But when I try to directly print the report to the printer, the report renders as Image (code for printing suggested from MSDN site), but prints only the half of the report in the printer and that too ugly to see as it looks like a drag.</p>
  
  <p>Report Width : 3.5in
  Report Height: 7in <br>
  please take a look at the code below I use and suggest your opinions.</p>
  
  <pre><code>    // RDLC InvoicePrintReport - Report Ready with Data Source and Parameters
        Export(InvoicePrintReport);
        Print();
  
      //Report Printing Section
      private int m_currentPageIndex;
      private IList&lt;Stream&gt; m_streams;
  
      private Stream CreateStream(string name, string fileNameExtension, System.Text.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;3.5in&lt;/PageWidth&gt;&lt;MarginTop&gt;0.01in&lt;/MarginTop&gt;&lt;MarginLeft&gt;0.01in&lt;/MarginLeft&gt;&lt;MarginRight&gt;0.1in&lt;/MarginRight&gt;&lt;MarginBottom&gt;0.01in&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;
      }
  
      private 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;
              //PaperSize pkCustomSize1 = new PaperSize("First custom size", 100, 200);
              //printDoc.DefaultPageSettings.PaperSize = pkCustomSize1;
  
              printDoc.Print();
          }
      }
  
      private void PrintPage(object sender, PrintPageEventArgs ev)
      {
          System.Drawing.Imaging.Metafile pageImage =
              new System.Drawing.Imaging.Metafile(m_streams[m_currentPageIndex]);
  
          // Adjust rectangular area with printer margins.
          System.Drawing.Rectangle adjustedRect = new System.Drawing.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(System.Drawing.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);
      }
  </code></pre>
  
  <p><a href="https://msdn.microsoft.com/en-us/library/ms252091.aspx?f=255&amp;MSPPError=-2147217396" rel="nofollow noreferrer">reference:printing local report</a></p>