Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pdf browser request goes into deep freeze

A client has a pdf newsletter that weighs in at 1.63 MB, so not huge.

We send out an email blast with a link to the pdf. Or else the users find a link on the home page of the site. It doesn't matter.

The problem is that when a user requests the PDF, the browser will sometimes go into a deep freeze. Ie, you need to use Task Manager to kill the browser instance.

You can test the pdf here: Newsletter

What makes it difficult is that it doesn't always fail. The following is a summary of where I am and what I have attempted.

BROWSERS

The most likely browser to fail with the pdf is Google Chrome. However, IE will also sometimes freeze up.

ERROR

Google Chrome will sometimes return the following error (after a long wait):

"There was an error processing the page. A file I/O error has occured. The file connection timed out."

IE just freezes to death without a whimper.

ACROBAT VERSION

The file was originally created in Adobe InDesign CS3, by a design studio. We just get the pdf. I have tried resaving the file using Acrobat 7 in case there was some compatibility issue. This seemed to clear the problem on one machine, but not on others...

GOOGLE RESULTS

Googling shows that there are some issues with Chrome and PDFs. I have yet to find any solution. This still doesn't explain why IE fails sometimes.

OTHER MEASURES

I clear the cache for each browser between tests. So it can't just be a mangled download.

OPENING THE FILE WITH ACROBAT PRO

There is no problem opening the file this way.

WEB SERVER

The web server people have tested the file and have had no problems. They can find no issues in the logs, which indicates that the file downloads, and that the problems happen within the browser.

HELP!

The newsletter should have gone two days ago, but we are holding it whilst trying to solve this issue. The bad news is that I have run out of ideas.


EDIT:

WORKAROUND:

I followed up on pestaa's suggestion (see answer below), which provides a workaround that works. Not optimal for the type of user (medical charity for Encephalitis, which can leave sufferers with brain injury), but it works. Ie, attach the following http header:

Content-Disposition: attachment

To do this, I have created a page that that has a button with the following code:

protected void downloadButton_Click(object sender, EventArgs e)
    {
        string fileName = "newsletter49.pdf";

        string filePath = Server.MapPath("~/images/ipdf/mailings/" + fileName);
        Response.Clear();

        Response.AppendHeader("content-disposition", "attachment; filename=" +       fileName);
        Response.ContentType = "application/octet-stream";
        Response.WriteFile(filePath);
        Response.Flush();
        Response.End();
    }

The html for the page (includes button for downloading Acrobat Reader as required by W3C standards):

<h2>
        Our Autumn/Winter 2010 Newsletter is now available</h2>
    <p>
        Please click on the button below:</p>
    <asp:Button ID="downloadButton" runat="server" OnClick="downloadButton_Click" Text="Download Newsletter" />
    <div style="margin-top: 10px; border: 1px solid #ccc; background: #ebebeb; padding: 6px;">
        <p>
            If you do not have Adobe Acrobat Reader, you will not be able to read the Newsletter.
            To get Acrobat Reader, click the button below and download it from Adobe's website:</p>
        <a title="This link opens in a new window to allow you to download Adobe Reader!"
            href="http://get.adobe.com/uk/reader" target="_blank">
            <img alt="Get Adobe Reader for viewing PDF files" src="../Images/SharedImages/get_adobe_reader.gif"
                style="border: none;" /></a>
    </div>

I am waiting to see if anyone can figure out what might be wrong with the pdf. Otherwise, pestaa will get the biscuit.


EDIT 2:

I have accepted pestaa's suggestion as being the only reliable course. Not ideal, given that this is a medical charity for a syndrome that can produce brain damage, so the extra steps of downloading then opening the pdf are onerous. But it is no good if the browser crashes on them.

If anyone hears of this issue being fixed, please leave a comment.

like image 649
awrigley Avatar asked Nov 11 '10 15:11

awrigley


1 Answers

This may not precisely be what you're looking for, but if downloading the PDF is enough or fine, this is the HTTP header you need to attach when sending the content:

Content-Disposition: attachment

This forces the browser to popup the open/save dialog, and probably solves the the buggy IE case.

like image 164
pestaa Avatar answered Sep 27 '22 17:09

pestaa