-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using download_filename in render_pdf changes functionality #8
Comments
That’s not how browsers work. The Without a APP.route("/to-pdf/PDF-<string:id>.pdf")
def to_pdf(id):
... By the way, you could use something like |
Ok thanks. In this case i actually cant use the url_for() since my id is actually set via javascript, unless there's some flask stuff i'm not aware of that lets you do that. I just used that flask-set-id in my example for simplicity. Anyway, now i know a little bit more about how browsers work. |
|
Hello, everyone It would be a good option to add an This way the behavior would be exactly what @SirNeuman needs. If the user clicks to download, the file's name would have the desired name. |
Previously I used:
Python:
HTML:
<a href="/to-pdf/{{id}}" target="_blank">
And it worked as expected. Upon clicking the a-tag the browser would display the pdf in a new tab. However I decided that i wanted a specific filename for when users downloaded the pdf from the browser. so i changed the Python to:
As per the flask-weasyprint documentation. Now, however, upon clicking the a-tag a new tab does not open, and it just downloads directly to the computer without a preview. It still generates the same pdf, but I would like it to keep the functionality as before with the addition of a default custom filename. So basically I'm wondering how i can set the default filename for downloading a file, without changing the url and while still allowing the pdf to be viewable in the browser (i.e. not download directly to the computer). Thanks
The text was updated successfully, but these errors were encountered: