diff options
Diffstat (limited to 'wkhtmltopdf')
-rw-r--r-- | wkhtmltopdf/tests/tests.py | 5 | ||||
-rw-r--r-- | wkhtmltopdf/views.py | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/wkhtmltopdf/tests/tests.py b/wkhtmltopdf/tests/tests.py index f2d92aa..7365d05 100644 --- a/wkhtmltopdf/tests/tests.py +++ b/wkhtmltopdf/tests/tests.py @@ -8,6 +8,7 @@ import sys from django.conf import settings from django.test import TestCase from django.test.client import RequestFactory +from django.utils import six from django.utils.encoding import smart_str from wkhtmltopdf.subprocess import CalledProcessError @@ -190,8 +191,8 @@ class TestViews(TestCase): self.assertTrue(static_url in footer_content, True) pdf_content = response.rendered_content - self.assertTrue(pdf_content.startswith(b'%PDF-')) - self.assertTrue(pdf_content.endswith(b'%%EOF\n')) + title = '\0'.join(cmd_options['title']) + self.assertIn(six.b(title), pdf_content) def test_pdf_template_response_to_browser(self): self.test_pdf_template_response(show_content=True) diff --git a/wkhtmltopdf/views.py b/wkhtmltopdf/views.py index 1c57869..2f1945d 100644 --- a/wkhtmltopdf/views.py +++ b/wkhtmltopdf/views.py @@ -5,6 +5,7 @@ from tempfile import NamedTemporaryFile from django.conf import settings from django.http import HttpResponse from django.template.response import TemplateResponse +from django.utils.encoding import smart_str from django.views.generic import TemplateView from .utils import (content_disposition_filename, make_absolute_paths, @@ -73,7 +74,7 @@ class PDFTemplateResponse(TemplateResponse, PDFResponse): context = self.resolve_context(self.context_data) - content = template.render(context) + content = smart_str(template.render(context)) content = make_absolute_paths(content) try: |