In this video, I’ll show you how to dynamically generate PDF files from Jinja HTML templates using Flask.
You’ll be using the Python library called PDFKit to do this.
Need one-on-one help with your project? I can help through my coaching program. Learn more here:
To download the cheat sheet, go here:
Join my free course on the basics of Flask-SQLAlchemy:
Documentation for PDFKit and wkhtmltopdf:
…(read more)
Convert Word 2 PDF: Word to PDF Converter
Convert PowerPoint 2 PDF: PPT to PDF Converter
Convert Excel 2 PDF: Excel to PDF Converter
Convert an Image 2 PDF: Image to PDF Converter
Convert HTML 2 PDF: HTML to PDF Converter
More Tools: PDF Converter
Join my free course on the basics of Flask-SQLAlchemy: https://prettyprinted.com/flasksql
Can I use send_file?
This is so simple, yet amazing
I can just pass down invoice data from my database in flask, let it generate invoices and download
and I don't even have to learn some weird syntax of some silly library because I can just design it in html and pass in my objects as jinja variables
Nice!
When the request is completed does it automatically flush the generated pdf file from memory or do we have to do it manually?
Tyvm Anthony this video helped me a lot, I'll take your Flask-SQLAlchemy course
thanks man!!! worked for me
you helped me with my computer science project, thank you!
im using jinja2 template with flask and when i render it gives "url_for" error which im using in base_layout. removing url_for from base layout and referencing absolute path but didnt succeed . any help ?
Did you install this inside your flask virtual environment? If so, how? Thank you!!
Veryy useful! Thank youu!
2020 u saved my life man, and i just bought ur Udemy course u got some pretty cool stuff in there i suggest you do another one.
Any tip for Working with api that generates such pdfs with post request to route (with FormData or Json) over cross domain/site.
Awesome video, but how can we set meta data for pdf using pdfkit module
i am making book reading and book download website but the real question is how can i just fetch 500 page book pdf to html template and then try this method to again make that thing avaiable at my site like direct real that book
very good, thanks!!!
pretty printed could you help me storing files in a file system rather than directly in. a database. If possible, give me a article or related video that can help me store files with paths in a mysql db and using flask and python.
thank you
how would you generate pdfs without the dynamic urls
I need to do it but deployed from HEROKU, but being on the internet does not work
Necesito hacerlo pero desplegado desde HEROKU, pero al estar en internet no sirve
How to make this PDF editable?
OSError: No wkhtmltopdf executable found: "b''"
great video!, thank for your help.
Hey! , is it possible to give a specific path for where it should save the generated pdf? Thanks!
Awesome as usual. Quick question: How demanding server side is something like this? Will adding this feature use up all my allowance of CPU usage on my Azure webpage? (If it was doing say <100 a day?)
2019, once again Anthony save my life. Thanks so much!!!!
wow great video
very helpful for my project. Thanks Man
شكرا لك in arabic
Thank you sir its nice
I am self taught and I have been following your awesome tutorials closely to learn fast and well, I am implementing an app that send users "stuff" to the supervisor requesting to authority to do something, the supervisor receives a mail with accept/reject buttons which are supposed to auto-generate official pdf doc response back to the user . the link does exist yet on clicking one of the button I get error message of the route not existing. what is the best approach to this?
Thanks a lot.
Could you upload the src for creating the Flask Cheat Sheet?
Is it possible to extract image out of this?
How about this flask extension?
https://pythonhosted.org/Flask-WeasyPrint/
Looks like so more simple to use.
how to display a pdf on document on webpage itself rather than going to next tab .For example displaying ppts in slideshare
For people who got this ERROR: "OSError: No wkhtmltopdf executable found: "b''"
I've added additional 2 lines to make it work:
path_wkthmltopdf = r'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe'
config = pdfkit.configuration(wkhtmltopdf=path_wkthmltopdf)
rendered = render_template('pdf_template.html', name=name , location=location)
pdf = pdfkit.from_string(rendered, False, configuration=config)
or you can add it to environment variables. Either way, it works.
Hope it helps someone 🙂
Thanks
I'm a simple man, I see pretty printed, I click like
WEY TE LA MAMASTE <3
how can i add image in pdf ?