This is one of those issues that caught me by surprise as i thought it would be easy to do.
There are several threads on the subject but no working solution.
The goal:
Create a pdf resource that will automatically trigger a pdf download when navigated to.
The problem:
PDF download is 0KB in size and cannot be opened.
The attempts:
Attempt 1 - Failed
Setup a resource with Resource Type: Web page, Media type: application/pdf, Content disposition: attachment, and blank template. In the content i had a call to a snippet like so:
[!LoadFile?&file=`assets/files/file.pdf`!]
to this little snippet:
<?php
# Snippet to include files from filesystem
# [[LoadFile?&file=`assets/folder/file.tpl`]]
$path=$modx->config['base_path'];
if ( !isset($file) || $file== "" ) return "No file specified."; //check if there's a file given.
if(is_file($file))
{
// required for IE
if(ini_get('zlib.output_compression')) { ini_set('zlib.output_compression', 'Off'); }
readfile($file);
return;
}
?>
Attempt 2 - Failed
Installed FileDownloadPE snippet from
http://modx.com/extras/package/filedownloadpe
Followed the snippet instructions to setup downloads template, tvs, and resources.
I understand that Revo has static resources just for this. Unfortunately the client is reluctant to migrate so we have to deal with Evo for now.
It seems that this is a very common use case. Does anybody have pdf resources working?
Thanks in advance.
[ed. note: outre99 last edited this post 14 years, 10 months ago.]