Page 1 sur 1

Lecture PDF

Posté : 22 juin 2006, 12:37
par spaceduck
Bonjour,
je voudrais afficher le contenu d'un PDF dans une page web
j'ai donc inclus les headers suivants :

header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/pdf');
header("Content-disposition: filename=download.pdf");

et je lis ensuite mon fichier :
echo file_get_contents($this->PHP); // où $this->PHP contient l'adresse de mon fichier

le problème est que le navigateur me propose de le télécharger, et non de l'afficher

je ne trouve pas la réponse sur le Net, quelqu'un aurait-il une idée ?
Merci d'avance, a+

Posté : 22 juin 2006, 14:39
par Orni
Tiré du site php.net
If you use the content type image/png instead of application/pdf when sending a PDF file on the header you can override the Famous IExplorer Bug ;).

$len = filesize($filename);
header('Content-type: image/jpeg');
header('Content-Length: $len');
header('Content-Disposition: inline; filename="filename.pdf"');
readfile($filename);

IExplorer tries to open the picture but because of the file-extension .pdf , voila. The acrobat reader plugin opens the file without even ask you for download.

I've read somewhere, "there is no turnarround on this bug, please install service pack 2".

There is always a turnarround :)

Have fun!!!

Ra�l Raja Martinez. dobleerre_AT_estudiowebs-DOT-com
A tester bien évidemment 8)