aboutsummaryrefslogtreecommitdiffstats
path: root/wkhtmltopdf/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'wkhtmltopdf/views.py')
-rw-r--r--wkhtmltopdf/views.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/wkhtmltopdf/views.py b/wkhtmltopdf/views.py
index bd1da13..c337b6c 100644
--- a/wkhtmltopdf/views.py
+++ b/wkhtmltopdf/views.py
@@ -1,6 +1,5 @@
from __future__ import absolute_import
-import os
from re import compile
from tempfile import NamedTemporaryFile
import warnings
@@ -8,7 +7,6 @@ import warnings
from django.conf import settings
from django.contrib.sites.models import Site
from django.http import HttpResponse
-from django.template.context import RequestContext
from django.template.response import TemplateResponse
from django.views.generic import TemplateView
@@ -16,6 +14,8 @@ from .utils import (content_disposition_filename, wkhtmltopdf)
class PDFResponse(HttpResponse):
+ """HttpResponse that sets the headers for PDF output."""
+
def __init__(self, content, mimetype=None, status=200,
content_type=None, filename=None, *args, **kwargs):
@@ -134,10 +134,17 @@ class PDFTemplateResponse(TemplateResponse, PDFResponse):
class PDFTemplateView(TemplateView):
+ """Class-based view for HTML templates rendered to PDF."""
+
+ # Filename for downloaded PDF. If None, the response is inline.
filename = 'rendered_pdf.pdf'
- footer_template = None
+
+ # Filenames for the content, header, and footer templates.
+ template_name = None
header_template = None
+ footer_template = None
+ # TemplateResponse classes for PDF and HTML
response_class = PDFTemplateResponse
html_response_class = TemplateResponse