Well, the link is made just like any other link.
For the PDF URL, use a Content-type of application/pdf and set the Content-disposition header too.
| [reply] [d/l] [select] |
Thanks for your reply. But just change the content-type is not worked. It ask to download the file, but when we try to open it in adobe reader, it shows error message as it is not a supported format. I think its because we are trying to open a text file using adobe.
Below is the code I tried.
<%init>
$r->content_type('application/pdf');
$r->headers_out->{'Content-disposition'} = "attachment; filename=report.pdf";
$m->print('test');
</%init>
| [reply] |
'test' isn't a valid PDF file. If you are actually trying to serve a PDF file, open it and send the content appropriately. If you simply think you can send any text and have Adobe PDF reader open it as a PDF file, you're mistaken. In that case you'd need to create a PDF then serve it.
| [reply] |
By far the easiest way to grok this sort of magic is simply to go to a site that is now doing what you want, and then to examine the HTML response-packet that was returned using the browser’s own built-in (or add-on...) debugging facilities. The secret sauce to this particular problem is, indeed, the specifying of content-type and/or disposition in the HTML header. But a concrete example is worth a thousand guesses, and in this case it is very easily obtained.
| |