Making PDFs downloading...

Making PDFs downloading...

by Maik Riecken -
Number of replies: 3
... for earlier Acrobats versions there was a security fix in moodle (1.6? , 1.7?) making pdfs not appear inside the browserplugin. The user was being asked for download or opening by external viewer.

Does anyone know what has to be changed in code to get this behaviour back? Petr Skoda added this fix before.

this would be really great, because we've got some trouble with old fashioned AdobeReaders on germany's school computers...

Maik
Average of ratings: -
In reply to Maik Riecken

Re: Making PDFs downloading...

by Luke Hudson -
Hi there. As Ralf has said, you should be able to change this in the browser. However, if you need to make the change 'globally', you can change it in Moodle.

I don't know exactly which version you're running, so the exact location may not be the same, but have a look at the file lib/filelib.php around line 234.

You should see something like the following code.
If you do, try removing the lines which are marked below in red, and adding those marked in green in their place.
The bold black parts should remain the same.

//Adobe Acrobat Reader XSS prevention
if ($mimetype=='application/pdf' or mimeinfo('type', $filename)=='application/pdf') {
//please note that it prevents opening of pdfs in browser when http referer disabled
//or file linked from another site; browser caching of pdfs is now disabled too
if (empty($_SERVER['HTTP_REFERER']) or strpos($_SERVER['HTTP_REFERER'], $CFG->wwwroot)!==0) {
$mimetype = 'application/x-forcedownload';
$forcedownload = true;
$lifetime = 0;
} else {
$lifetime = 1; // >0 needed for byteserving
}
$mimetype = 'application/x-forcedownload';
$forcedownload = true;
$lifetime = 0;

}


I hope this helps you, basically it tries to pass the browser the right information to force it to download the file, instead of viewing it inside the browser window.

Cheers,
- Luke Hudson
In reply to Luke Hudson

Re: Making PDFs downloading...

by Maik Riecken -
Hi Ralf, hi Luke,

It is a setting in my browser. But not anyone is able to take this setting and older AcrrobatReaders-plugins (win98) fail to display PDFs correctly within the browser. We are talking about "non-tech" teachers and students and their computers protected by hardware cards for changing settings... So we have to force this...

regards and thanks for your help - it works!

Maik