title: Dynamically Create PDF file and Bind to Pdf Viewer control
body: <p>I am generating an ssrs report in my <em>Silverlight</em> application and I need to convert the <em>ssrs report</em> to <code>RadPDFViewer control</code>(telerik silverlight). 
  So I am saving the pdf file in the project folder using WCF. 
  Now i need to read the file again and bind it to <em>Pdfviewer</em>.</p>
  
  <p>Saving happens asynchronously. 
  How should I wait untill the file is saved and then read from the folder?</p>
  
  <p>Also, can you please show me how to read the PDF as a Memory stream.</p>
  
  <p>I run the following code unsuccessfully.</p>
  
  <pre><code>public byte[] ReturnPdf(string requestUrl) {
          HttpWebRequest req = null; var buf = new byte[1024];
          try
          {
                  req = (HttpWebRequest)WebRequest.Create(requestUrl);
  
                  req.Credentials = CredentialCache.DefaultCredentials;
  
                  req.Method = "GET"; var objResponse = req.GetResponse();
                  var stream = objResponse.GetResponseStream();
                  if (stream != null){BinaryReader br = new BinaryReader(stream);
                          buf = br.ReadBytes(1024);
                  } if
                  (stream != null) stream.Close();
  
          }
          catch Exception e){}return buf;
  }
  
  private void button2_Click(object sender, EventArgs e)
  {
  
          string baseUrl = "http://abc/ReportServer&amp;rs:Command=Render&amp;rs:ClearSession=true&amp;rs:Format=PDF";
  
          const string nullString = ":isnull=true";
  
  
          byte[] o = ReturnPdf(baseUrl);
  
          byte[] bytes = new byte[1024];
          Stream s = new MemoryStream(bytes);
  
  }
  </code></pre>