🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.reader
Article #15634

Unable to read streamed PDF content embedded in broswer

#15634
From: Matt_N_Morton
Date: Thu, 06 Jul 2006 16:18
34 lines
2232 bytes
I have a web application that, for security reasons, writes PDF content to the Response object, rather than having the browser redirect to the source file. This works great for users with most browser/Adobe reader combinations. However, with some(specifically IE5 on WIN2000 with Adobe 6.x), the browser window is empty. And if you open Reader directly, you see the pdf. I figure there is some piece of Content Header that I'm omitting, that's preventing the binary stream from being displayed in the browser. This is what I have:

int bufferSize = 1024; // Size of the buffer.
byte[] outbyte = new byte[bufferSize]; // The byte[] buffer to be filled.
long retval; // The bytes returned

Response.AddHeader("Content-Type", "application/PDF");
Response.AddHeader("Content-Length", new FileInfo(fileName).Length.ToString() );
Response.AddHeader("Content-Disposition", "inline; filename=fileName.PDF");

// need a FileStream //
using(FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read))
{
    do
    {
        // fill the buffer with data //
        retval = fileStream.Read(outbyte, 0, bufferSize);

// make sure we read some data //
        if (retval != 0)
        {
            // output to the writer //
            Response.OutputStream.Write(outbyte, 0, (int)retval);
        }
    }
    while (retval > 0); // any more data to read?

// write the leftovers //
    Response.OutputStream.Write(outbyte, 0, (int)retval);
}
Response.Flush();

I was hoping that someone may be able to provide the Content headers that I'm missing. Any help would be greatly appreciated.
Thanks.
Technical Details
Message-ID: <3bc0d48c.-1@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.germany.com!news.datemas.de!news.albasani.net!news.ecp.fr!news.stben.net!webcrossing

Show Full Headers
Complete Article Headers
X-Google-Thread: 10273d,3979da6abf6aa11a,start
X-Google-Attributes: gid10273d,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Matt_N_Morton@adobeforums.com
Newsgroups: adobe.reader
Subject: Unable to read streamed PDF content embedded in broswer
Message-ID: <3bc0d48c.-1@webcrossing.la2eafNXanI>
Date: Thu, 6 Jul 2006 09:18:26 -0700
Lines: 46
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.germany.com!news.datemas.de!news.albasani.net!news.ecp.fr!news.stben.net!webcrossing