walid mousbah

walid mousbah

  • NA
  • 10
  • 11.9k

Saving stream as a PDF file to disk

Jun 24 2015 6:20 PM
Hi,
This example retrieves a pdf document.  
How can I save the data as a pdf file to disk?
Thanks

string jsonResponse ;
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(string uri);
webRequest.Method = "GET";
webRequest.Accept = "application/pdf";

using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
{
  using (StreamReader reader = new StreamReader(webResponse.GetResponseStream()))
  {

    jsonResponse = reader.ReadToEnd();

  }
}

Answers (3)