Re: Problem with Internet Explorer when downloading / viewing dynamically generated PDF files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Frank Arensmeier said the following on 09/22/05 03:59:

> Explorer shows the PDF document as plain text only. Trying to save the
> linked document to the computer (right click) gives something like "The
> server can not be reached or the document does not exist."
> 
> I know that explorer is a real p.i.t.a. when it comes to all kinds of
> web standards. And my best guess is that this could have to do with
> headers, or?

I've been down this road...

The following works for me.  Note that it will cause IE to open the PDF
via the acrobat reader plugin, if you want to force IE to download the
PDF you'll need to change the header (look at the header page from
php.net for info).

    // Dump the PDf to the browser

$filename="FileNumber".$_SESSION['fileNumber']."_ReportNumber".$_SESSION['reportNumber'].".pdf";
    $len=strlen($reportPDF);
    if(isset($_SERVER['HTTP_USER_AGENT']) &&
        preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT'])) {
        // IE Bug in download name workaround
        ini_set( 'zlib.output_compression','Off' );
    }
    header("Content-type: application/pdf");
    header("Content-Length: $len");
    header("Content-Disposition: inline; filename=".$filename);
    print $reportPDF;


Let me know if this doesn't solve your problem.

- Ben

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux