|
private Stream DownloadPdfStream(string URL)
{
try
{
//Initialize WebClient
WebClient webClient = new WebClient();
// Initialize Uri
var uri = new System.Uri(URL);
//Returns the document stream from the given URL
Stream InputStream = webClient.OpenRead(uri);
byte[] result;
using (var streamReader = new MemoryStream())
{
InputStream.CopyTo(streamReader);
result = streamReader.ToArray();
}
return new MemoryStream(result);
}
catch (Exception exception)
{
return null;
}
} |