By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,433 Members | 776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,433 IT Pros & Developers. It's quick & easy.

Force PDF Download & Acrobat Reader Plugin

P: 27
Does anyone know how I can prevent the Acrobat Reader plugin from loading a pdf into the web browser? I need to force the user to download the pdf file and run the pdf using the full Adobe Acrobat Reader program.

The code I'm using at present isn't working - any browser with the plugin loaded doesn't download the file it gets loaded into the browser window via the plugin:

[PHP]<?php

$mytalk = $_GET['varrqust'];

if($_GET['varrqust'] == "1"):
$mytalk = 'Talk 1';
$talksize = 3Mb';
$talkpath = 'talk1.pdf';

elseif($_GET['varrqust'] == "2"):
$mytalk = 'Talk 2';
$talksize = '3Mb';
$talkpath = 'talk2.pdf';

elseif($_GET['varrqust'] == "3"):
$mytalk = 'Talk 3';
$talksize = '3Mb';
$talkpath = 'talk3.pdf';

endif;

$path = $talkpath;
$file = basename($path);
$size = filesize($path);

//do download
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=$file");
header("Content-Transfer-Encoding: binary");
header("Content-Length: $size");

@readfile($path);

exit();

?>[/PHP]

Thanks in advance.
Oct 11 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.