diff options
author | George Hickman <george@ghickman.co.uk> | 2012-03-20 17:27:10 +0000 |
---|---|---|
committer | George Hickman <george@ghickman.co.uk> | 2012-03-20 17:27:10 +0000 |
commit | 05abe3631696df591c5765ba13426febd6655a30 (patch) | |
tree | a65951c8049009a7206528e66c15d1bd4d74683d /docs/usage.rst | |
parent | d3a3522cea3cf553ddf2f9345b01b548ddd6cf0c (diff) | |
download | django-wkhtmltopdf-05abe3631696df591c5765ba13426febd6655a30.tar.gz django-wkhtmltopdf-05abe3631696df591c5765ba13426febd6655a30.tar.bz2 django-wkhtmltopdf-05abe3631696df591c5765ba13426febd6655a30.zip |
Start the docs
Diffstat (limited to 'docs/usage.rst')
-rw-r--r-- | docs/usage.rst | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/docs/usage.rst b/docs/usage.rst new file mode 100644 index 0000000..fe883f3 --- /dev/null +++ b/docs/usage.rst @@ -0,0 +1,58 @@ +Usage +===== + +The ``PDFTemplateView`` takes a selection of variables, most of which get passed +to the underlying wkhtmltopdf binary. The exceptions are: + +* filename +* footer_template +* header_template +* response +* template_name + +wkhtmltopdf options can be found by running ``wkhtmltopdf --help``. Unfortunately +they don't provide hosted documentation. Any variables you pass to django-wkhtmltopdf +need to be underscored. They will be converted to hyphenated variables for use with +the wkhtmltopdf binary. + +.. note:: + + For convenience in development you can add the GET arg ``?as=html`` to the + end of your URL to render the PDF as a web page. + + +Simple Example +-------------- + +Point a URL at PDFTemplateView: + +.. code-block:: python + + from django.conf.urls.defaults import * + from django_wkhtmltopdf.views import PDFTemplateView + + + urlpatterns = patterns('', + # ... + url(r'^pdf/$', PDFTemplateView.as_view(template_name='my_template.html', + filename='my_pdf.pdf'), name='pdf'), + # ... + ) + + +Advanced Example +---------------- + +Point a URL (as above) at your own view that subclasses ``PDFTemplateView`` and +and override the sections you need to. + +.. code-block:: python + + from django_wkhtmltopdf.views import PDFTemplateView + + + class MyPDF(PDFTemplateView): + filename = 'my_pdf.pdf' + margin_top = 3 + template_name = 'my_template.html' + |