Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Rendering a PDF from a FileStream fails in Chrome

$
0
0

Hi

I’m using the following code to server up different documents to user of our extranet from a share on one of our servers.  It works perfectly in Internet Explorer and FireFox but fails in Chrome and possibly in Safari too.

In IE the pdf opens immediately in the browser.  In Chrome the page loading progress marker in the bottom left goes from 12 o’clock around to 9 o’clock and then nothing happens.

If I ‘inspect the element’ I see the following html:

     <embed width="100%" height="100%" name="plugin" src="http://extranet/testing/default.aspx" type="application/pdf">

Is it failing because it is trying to render my default.aspx page as a pdf?  If so, why does it work ok in Internet Explorer?  What do I have to do to pass it the correct source of my pdf?

Thanks in advance,

Matt

 

string path = @"\\server\Share\file.pdf";

FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);

int fileSize = (int)fileStream.Length;
byte[] buffer = new byte[fileSize];
 
fileStream.Read(buffer, 0, fileSize);
fileStream.Close();

Response.ContentType = "application/pdf"
Response.OutputStream.Write(buffer, 0, fileSize);
Response.Flush();
Response.Close();


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>