Convert JavaScript dependent Flask templates into PDFs with wkhtmltopdf.
Project description
Flask-WkHTMLtoPDF
Flask-WkHTMLtoPDF allows you to easily convert JavaScript dependent Flask templates into PDFs with wkhtmltopdf. For complete documentation, please visit http://flask-wkhtmltopdf.readthedocs.org/en/latest/?badge=latest.
Installation
Install the extension with one of the following commands:
$ easy_install flask-wkhtmltopdf
or alternatively if you have pip installed:
$ pip install flask-wkhtmltopdf
You will also need to install the WkHTMLtoPDF command line library from http://wkhtmltopdf.org/downloads.html. Alternatively, you can install from the command line for unix based machines by finding the appropriate distrubution on http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/. For instance, for linux:
$ wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-precise-amd64.deb
$ sudo dpkg -i wkhtmltox-0.12.2.1_linux-precise-amd64.deb
Usage
First setup in your main Flask file.
from flask_wkhtmltopdf import Wkhtmltopdf
app = Flask(__name__)
wkhtmltopdf = Wkhtmltopdf(app)
Then add these to your app's config
WKHTMLTOPDF_BIN_PATH = r'C:\Program Files\wkhtmltopdf\bin' #path to your wkhtmltopdf installation.
PDF_DIR_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static', 'pdf')
To convert a flask template into a PDF, simply use the render_template_to_pdf() function.
render_template_to_pdf('test.html', download=True, save=False, param='hello')
Contributing
Contributions are more than welcomed. Please follow these steps:
- Fork this repository
- Make your changes
- Test your changes locally:
$ python setup.py test
- Submit a pull request
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file Flask-WkHTMLtoPDF-tmsl-0.1.2.tar.gz
.
File metadata
- Download URL: Flask-WkHTMLtoPDF-tmsl-0.1.2.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86a7f0622de51780351d169bdae4105ae1b437ea843d39ed98ee9c8c5ba13328 |
|
MD5 | 9f059400bad09790008d411e6963423c |
|
BLAKE2b-256 | 5dfefa6db601469cb670da61e12be900ffebc4750bba850b49b7f52680dfb5ec |
File details
Details for the file Flask_WkHTMLtoPDF_tmsl-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: Flask_WkHTMLtoPDF_tmsl-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc1212afc7644fe8bbc8aee972e251a096f5a7363878c028000297a44fb6e393 |
|
MD5 | d2c18af550b7e0904c1d81a33d473c46 |
|
BLAKE2b-256 | 4c58c8fd532566e0ff9cd7c3b272c78e212b5ec50f515864fe11b75aa89b894c |