diff options
author | Simon Law <simon.law@ecometrica.com> | 2012-07-20 15:58:55 -0400 |
---|---|---|
committer | Simon Law <simon.law@ecometrica.com> | 2012-07-20 15:58:55 -0400 |
commit | 803aba8859109e2c17e4bdf53126c058a2b60918 (patch) | |
tree | b18aaa217f70cf23aa0bf3615860a282afed8249 | |
parent | 6f7d08e0ec7b3c46ea6e9e6aae7fbc9327df29b4 (diff) | |
download | django-wkhtmltopdf-803aba8859109e2c17e4bdf53126c058a2b60918.tar.gz django-wkhtmltopdf-803aba8859109e2c17e4bdf53126c058a2b60918.tar.bz2 django-wkhtmltopdf-803aba8859109e2c17e4bdf53126c058a2b60918.zip |
settings.WKHTMLTOPDF_CMD_OPTIONS sets default command-line options.
-rw-r--r-- | README.rst | 10 | ||||
-rw-r--r-- | wkhtmltopdf/utils.py | 9 |
2 files changed, 16 insertions, 3 deletions
@@ -34,3 +34,13 @@ specific execuatable: e.g.: in ``settings.py``:: WKHTMLTOPDF_CMD = '/path/to/my/wkhtmltopdf' + +You may also set +``WKHTMLTOPDF_CMD_OPTIONS`` +in ``settings.py`` to a dictionary of default command-line options. + +The default is:: + + WKHTMLTOPDF_CMD_OPTIONS = { + 'quiet': True, + } diff --git a/wkhtmltopdf/utils.py b/wkhtmltopdf/utils.py index ce32621..7fe432a 100644 --- a/wkhtmltopdf/utils.py +++ b/wkhtmltopdf/utils.py @@ -1,5 +1,6 @@ from __future__ import absolute_import +from copy import copy from itertools import chain from os import fdopen import sys @@ -56,9 +57,11 @@ def wkhtmltopdf(pages, output=None, **kwargs): output = '-' # Default options: - options = { - 'quiet': True, - } + options = getattr(settings, 'WKHTMLTOPDF_CMD_OPTIONS', None) + if options is None: + options = {'quiet': True} + else: + options = copy(options) options.update(kwargs) cmd = getattr(settings, 'WKHTMLTOPDF_CMD', 'wkhtmltopdf') |