in reply to How to create a pdf download link using Mason?

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.

Replies are listed 'Best First'.
Re^2: How to create a pdf download link using Mason?
by daxim (Curate) on Jun 08, 2012 at 10:55 UTC
Re^2: How to create a pdf download link using Mason?
by aneeshk (Initiate) on Jun 08, 2012 at 11:27 UTC
    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>

      '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.