title: Render report quality EMF versus PDF
body: <p>I'm having difficulties rendering a SSRS serverreport and printing it from code.</p>
  
  <p>Although rendering succeeds and the report is printed, the results in quality in the graphics are poor. The report itself has a high res 6kx1k GIF image for the logo. </p>
  
  <p>I've made image below to illustrate the difference between rendering using EMF versus PDF:</p>
  
  <p><img src="https://i.stack.imgur.com/rLUnD.png" alt="(PDF on the left, EMF on the right)"></p>
  
  <p>As you can see the font look great (no pixallation) and when rendering in PDF logo look good. However the EMF version has poor quality as you can see on the edges in the logo.</p>
  
  <p>Anyone came across this and solved it?</p>
  
  <p>I'm running SQL Server 2008R2 SP2 (10.50.4000)</p>
  
  <p>Code to render the report using EMF</p>
  
  <pre><code>public List&lt;byte[]&gt; Render()
  {
      // Setting credentials and reporting services uri
      ReportExecutionService reportService = new ReportExecutionService
          {
              Credentials = _credentials,
              Url = Settings.Default.ReportingService
          };
  
      // Prepare report parameter.
      ExecutionHeader execHeader = new ExecutionHeader();
      reportService.ExecutionHeaderValue = execHeader;
      reportService.LoadReport(_report, null);
      reportService.SetExecutionParameters(_parameters.ToArray(), "en-us");
  
      // Render
      bool startup = true;
      List&lt;byte[]&gt; streams = new List&lt;byte[]&gt;();
      int numberOfPages = 0;
      byte[] result = null;
      while (startup || result.Length &gt; 0)
      {
          startup = false;
          string devInfo = String.Format(@"&lt;DeviceInfo&gt;&lt;OutputFormat&gt;EMF&lt;/OutputFormat&gt;&lt;PrintDpiX&gt;150&lt;/PrintDpiX&gt;&lt;PrintDpiY&gt;150&lt;/PrintDpiY&gt;&lt;StartPage&gt;{0}&lt;/StartPage&gt;&lt;/DeviceInfo&gt;", numberOfPages + 1);
          string encoding, mimeType, extension;
          string[] streamIDs = null;
          Warning[] warnings = null;
          result = reportService.Render("IMAGE", devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
  
          if (result.Length &gt; 0)
          {
              streams.Add(result);
          }
          numberOfPages++;
      }
      return streams;
  }
  </code></pre>
  
  <p>Here's the printdocument implementation</p>
  
  <pre><code>public class PrintReport : PrintDocument
  {
      private int _currentPage;
      private  List&lt;byte[]&gt; _pages;
  
      public PrintReport()
      {
      }
  
      public List&lt;byte[]&gt; Pages
      {
          get { return _pages; }
          set { _pages = value; }
      }
  
      protected override void OnBeginPrint(PrintEventArgs e)
      {
          base.OnBeginPrint(e);
          _currentPage = 0;
      }
  
      protected override void OnPrintPage(PrintPageEventArgs e)
      {
          base.OnPrintPage(e);
  
          Stream pageToPrint = new MemoryStream(_pages[_currentPage]);
          pageToPrint.Position = 0;
  
          // Load each page into a Metafile to draw it.
          using (Metafile pageMetaFile = new Metafile(pageToPrint))
          {
              Rectangle adjustedRect = new Rectangle(
                      e.PageBounds.Left - (int)e.PageSettings.HardMarginX,
                      e.PageBounds.Top - (int)e.PageSettings.HardMarginY,
                      e.PageBounds.Width,
                      e.PageBounds.Height);
  
              // Draw a white background for the report
              e.Graphics.FillRectangle(Brushes.White, adjustedRect);
  
              // Draw the report content
              e.Graphics.DrawImage(pageMetaFile, adjustedRect);
  
              // Prepare for next page.  Make sure we haven't hit the end.
              _currentPage++;
              e.HasMorePages = _currentPage &lt; _pages.Count;
          }
      }
  
      protected override void OnQueryPageSettings(QueryPageSettingsEventArgs e)
      {
          e.PageSettings = (PageSettings)PrinterSettings.DefaultPageSettings.Clone();
      }
  }
  </code></pre>