title: View a PDF from SSRS / RDL
body: <p>I want to access an RDL to obtain the report as PDF.  I have</p>
  
  <pre><code>    static void Main()
      {
          string pdfOutputFIleName = @"C:\Development\testoutputAsPdf.pdf";
          var urlAsPdf = @"http://serverName/ReportServer/Reserved.ReportViewerWebControl.axd?ExecutionID=xxx&amp;Culture=1033&amp;CultureOverrides=False&amp;UICulture=9&amp;UICultureOverrides=False&amp;ReportStack=1&amp;ControlID=yyy&amp;OpType=Export&amp;FileName=Bug+Status&amp;ContentDisposition=OnlyHtmlInline&amp;Format=PDF";
  
          var client = new WebClient();
          client.UseDefaultCredentials = true;
  
          //client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
          client.Headers.Add("Content-Type", "application/pdf");
  
          Process(client, urlAsPdf, pdfOutputFIleName);
  
          Console.Read();
      }
  
      private static void Process(WebClient client, string url, string outputFileName)
      {
          Stream data = client.OpenRead(url);
          using (var reader = new StreamReader(data))
          {
              string output = reader.ReadToEnd();
              using (Stream s = File.Create(outputFileName))
              {
                  var writer = new StreamWriter(s);
                  writer.Write(output);
                  Console.WriteLine(output);                                        
              }
          }
      }
  </code></pre>
  
  <p>The URL works fine in my browser.  The program runs.  When I to open the PDF I receive an error in Adobe:</p>
  
  <blockquote>
    <p>There was an error opening this document.  The file is damaged and
    could not be repaired.</p>
  </blockquote>