diff options
author | Simon Law <simon.law@ecometrica.com> | 2012-07-25 15:40:01 -0400 |
---|---|---|
committer | Simon Law <simon.law@ecometrica.com> | 2012-07-25 15:40:01 -0400 |
commit | 85daece4ed63036ef9906d795c5e1cbe38253800 (patch) | |
tree | 0e3a6f7385434a14f138fc4c241f316379a7afb8 /docs/usage.rst | |
parent | 0abefd41b70b4e8afefb61d725a88f9728625fbf (diff) | |
download | django-wkhtmltopdf-85daece4ed63036ef9906d795c5e1cbe38253800.tar.gz django-wkhtmltopdf-85daece4ed63036ef9906d795c5e1cbe38253800.tar.bz2 django-wkhtmltopdf-85daece4ed63036ef9906d795c5e1cbe38253800.zip |
Documentation updates for new and updated behaviour.
Diffstat (limited to 'docs/usage.rst')
-rw-r--r-- | docs/usage.rst | 61 |
1 files changed, 46 insertions, 15 deletions
diff --git a/docs/usage.rst b/docs/usage.rst index 8f8d797..7d031d1 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -1,19 +1,48 @@ Usage ===== -The ``PDFTemplateView`` takes a selection of variables, most of which get passed -to the underlying wkhtmltopdf binary. The exceptions are: +The :py:class:`PDFTemplateView` is a Django class-based view. +By default, it uses :py:class:`PDFTemplateResponse` to render an HTML +template to PDF. +It accepts the following class attributes: -* filename -* footer_template -* header_template -* response -* template_name +:py:attr:`template_name` + The full name of a template to use as the body of the PDF. -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. +:py:attr:`header_template` + Optional. + The full name of a template to use as the header on each page. + +:py:attr:`footer_template` + Optional. + The full name of a template to use as the footer on each page. + +:py:attr:`filename` + The filename to use when responding with an attachment containing + the PDF. + Default is ``'rendered_pdf.pdf'``. + + If ``None``, the view returns the PDF output inline, + not as an attachment. + +:py:attr:`response_class` + The response class to be returned by :py:meth:`render_to_response` + method. + Default is :py:class:`PDFTemplateResponse`. + +:py:attr:`html_response_class` + The response class to be returned by :py:meth:`render_to_response` + method, when rendering as HTML. + See note below. + Default is :py:class:`TemplateResponse`. + +:py:attr:`cmd_options` + The dictionary of command-line arguments passed to the underlying + ``wkhtmltopdf`` binary. + Default is ``{}``. + + wkhtmltopdf options can be found by running ``wkhtmltopdf --help``. + Unfortunately they don't provide hosted documentation. .. note:: @@ -24,7 +53,7 @@ the wkhtmltopdf binary. Simple Example -------------- -Point a URL at PDFTemplateView: +Point a URL at :py:class:`PDFTemplateView`: .. code-block:: python @@ -43,7 +72,8 @@ Point a URL at PDFTemplateView: Advanced Example ---------------- -Point a URL (as above) at your own view that subclasses ``PDFTemplateView`` and +Point a URL (as above) at your own view that subclasses +:py:class:`PDFTemplateView` and override the sections you need to. .. code-block:: python @@ -53,6 +83,7 @@ and override the sections you need to. class MyPDF(PDFTemplateView): filename = 'my_pdf.pdf' - margin_top = 3 template_name = 'my_template.html' - + cmd_options = { + 'margin-top': 3, + } |