This isn't rocket science to most, but I had a hard time figuring out how to read a PDF via URL and saving it to disk. You can use the PDFBox dll for this, but for those who want to use pure .NET, here's some code:
Expand|Select|Wrap|Line Numbers
- The namespaces:
- using System.Text;
- using System.IO;
Expand|Select|Wrap|Line Numbers
- //sends the request, converts response to s stream
- HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(pdfURL);
- HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
- Stream reqStr = webResponse.GetResponseStream();
- //reads the response stream
- StreamReader sr = new StreamReader (reqStr,System.Text.Encoding.Unicode);
- //writes stream to a PDF file
- StreamWriter sw = new StreamWriter(savePathPDF, false, System.Text.Encoding.Unicode);
- sw.Write(sr.ReadToEnd());
- sw.Close();