Wkhtmltopdf wrapper
Project description
html2pdf
A simple python wrapper for wkhtmltopdf forked from python-wkhtmltopdf
Requirements
System:
Linux 32/64 or OSX only (Windows is not supported at this stage)
Xvfd
wkhtmltopdf
python 2.5+
Installation
wkhtmltopdf (Linux)
Install Xvfd:
$ sudo apt-get install xvfb
Install Fonts:
$ sudo apt-get install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic
Install wkhtmltopdf:
$ sudo apt-get install wkhtmltopdf
wkhtmltopdf (OSX)
Install wkhtmltopdf:
$ brew install wkhtmltopdf
python-wkhtmltopdf (Any Platform)
Development:
$ git clone https://bitbucket.org/luisfernando/html2pdf.git $ cd html2pdf $ virtualenv . $ pip install -r requirements.pip
PIP:
$ pip install git+https://bitbucket.org/luisfernando/html2pdf.git or from pypi $ pip install html2pdf
Usage
Simple Usage::
Render a URL:
from wkhtmltopdf import HTMLURLToPDF make_pdf = HTMLURLToPDF( url='http://www.example.com', output_file='~/example.pdf', ) make_pdf.render()
Render a HTML string:
from html2pdf import HTMLToPDF HTML = """ <!DOCTYPE html> <html> <body> <h1>Hello World</h1> </body> </html> """ h = HTMLToPDF(HTML, self.output_file)
Required Arguments:
url - the url to convert to pdf
output_file - the pdf file that you want to create
Optional Arguments:
enable-plugins (default: True)
disable-javascript (default: False)
no-background (default: False)
grayscale (default: False)
orientation (default: Portrait)
dpi (default: 100)
username (default: None)
password (default: None)
margin-bottom (default: 10)
margin-top (default: 10)
margin-left (default: 10)
margin-right (default: 10)
disable-smart-shrinking (default: False)
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.