Simple python wrapper for wkhtmltopdf
Project description
python-wkhtmltopdf
A simple python wrapper for the wkhtmltopdf lib (http://code.google.com/p/wkhtmltopdf/) with flash support.
Requirements
System:
Xvfd
wkhtmltopdf
flashplugin-nonfree
python 2.5+
Installation
wkhtmltopdf
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
Install flashplugin:
$ sudo apt-get install flashplugin-nonfree
python-wkhtmltopdf
From git:
$ git clone git@github.com:qoda/python-wkhtmltopdf.git $ cd python-wkhtmltopdf $ python setup.py install
Usage
Simple Usage::
Use from class:
from wkhtmltopdf import WKHtmlToPdf wkhtmltopdf = WKHtmlToPdf( url='http://www.example.com', output_file='~/example.pdf', ) wkhtmltopdf.render()
Use from method:
from wkhtmltopdf import wkhtmltopdf wkhtmltopdf(url='example.com', output_file='~/example.pdf')
Use from commandline (installed):
$ python -m wkhtmltopdf.main example.com ~/example.pdf
Use the api (installed):
$ python -m wkhtmltopdf.api & $ wget http://localhost:8888/?url=example.com&output_file=example.pdf
Required Arguments:
url - the url to convert to pdf
output_file - the pdf file that you want to create
Optional Arguments:
screen_resolution (default: [1024, 768])
color_depth (default: 24 (bit))
flash_plugin (default: True)
disable_javascript (default: False)
delay (default: 0 (millisecs))
orientation (default: Portrait)
dpi (default: 100)
no_background (default: False)
grayscale (default: False)
http_username (default: None)
http_password (default: None)
header_html (default: None)
footer_html (default: None)
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.