Skip to main content

Flask-WkHTMLtoPDF

build status doc status

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:

  1. Fork this repository
  2. Make your changes
  3. Test your changes locally:
$ python setup.py test
  1. Submit a pull request

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Flask-WkHTMLtoPDF-tmsl-0.1.2.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Flask_WkHTMLtoPDF_tmsl-0.1.2-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

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

Hashes for Flask-WkHTMLtoPDF-tmsl-0.1.2.tar.gz
Algorithm Hash digest
SHA256 86a7f0622de51780351d169bdae4105ae1b437ea843d39ed98ee9c8c5ba13328
MD5 9f059400bad09790008d411e6963423c
BLAKE2b-256 5dfefa6db601469cb670da61e12be900ffebc4750bba850b49b7f52680dfb5ec

See more details on using hashes here.

File details

Details for the file Flask_WkHTMLtoPDF_tmsl-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for Flask_WkHTMLtoPDF_tmsl-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fc1212afc7644fe8bbc8aee972e251a096f5a7363878c028000297a44fb6e393
MD5 d2c18af550b7e0904c1d81a33d473c46
BLAKE2b-256 4c58c8fd532566e0ff9cd7c3b272c78e212b5ec50f515864fe11b75aa89b894c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page