Found a solution.
response.headers['Content-Disposition'] = 'inline;
filename="{0}.pdf"'.format(reseller.businessname)
Using the 'attachment' keyword the file will just download. But with
'inline' it still displays and uses the custom filename if / when
downloaded.
On Mon, May 29, 2017 at 10:41 AM, Paul Ellis <[email protected]> wrote:
> I tried your suggestion like this:
> response.view = offer_number
> response.headers['Content-Type'] = 'application/pdf'
> return pdf.output(dest='S')
>
> but I still get the controller function name as the filename when
> downloading.
>
> On Thu, May 18, 2017 at 10:42 PM, Dave S <[email protected]> wrote:
>
>>
>>
>> On Tuesday, May 16, 2017 at 1:27:06 AM UTC-7, Paul Ellis wrote:
>>>
>>> Hello,
>>>
>>> I use pyfpdf to display some information from my my database. When I
>>> click save the filename is 'pdf_view' which is the name of the controller
>>> function.
>>>
>>> How can I change this? I want the name to also come from the database.
>>>
>>> With the help of others on here. I can make a download link without
>>> viewing the PDF with a custom filename. However, my client would really
>>> prefer to be able to download with a customer filename from the PDF view.
>>>
>>> This output call works fine. But the Autofill name is not taken from the
>>> variable passed to the function.
>>>
>>> return pdf.output(name=bname, dest='S')
>>>
>>>
>> fpdf? I haven't tried my sample for a while (like not having seen a
>> typo), but what I see is that the browser uses the page name (from the
>> charming "fpdfdemo" I've called the function).
>>
>> I'm specifying response.view = generic.pdf, I don't know if that is
>> relevant to the naming logic.
>>
>> /dps
>>
>>
>>
>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>> pic/web2py/OtWmSAU6NCE/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.