diff options
author | Simon Law <simon.law@ecometrica.com> | 2012-07-24 16:18:39 -0400 |
---|---|---|
committer | Simon Law <simon.law@ecometrica.com> | 2012-07-24 16:18:39 -0400 |
commit | a0da923c093f79e2205529c5f12fad620f3159a7 (patch) | |
tree | 58a4bba8a961b4bbedcc378eedab3e02d9185c6e /wkhtmltopdf/utils.py | |
parent | bde096a028c2705b8f56fb5fdcbbaed4b318862d (diff) | |
download | django-wkhtmltopdf-a0da923c093f79e2205529c5f12fad620f3159a7.tar.gz django-wkhtmltopdf-a0da923c093f79e2205529c5f12fad620f3159a7.tar.bz2 django-wkhtmltopdf-a0da923c093f79e2205529c5f12fad620f3159a7.zip |
PDFTemplateView.cmd_options contains all the options to pass to wkhtmltopdf
Before, command-line arguments were class-based. Unfortunately, this
means that you cannot add new command-line arguments without
subclassing.
Instead, PDFTemplateView.cmd_options is a dictionary of all
command-line arguments. PDFTemplateView.as_view(cmd_options={...}) now
works as expected.
!!!! WARNING !!!!
cmd_options is now empty, leaving wkhtmltopdf with its default
behaviour. Explicitly add the options you want. Existing subclasses of
PDFTemplateView will now break, but a PendingDeprecationWarning will be
issued. Margins will now be wkhtmltopdf's default of 10mm.
PdfTemplateView contains a compatibility shim with the old default
values for margins and orientation.
Diffstat (limited to 'wkhtmltopdf/utils.py')
-rw-r--r-- | wkhtmltopdf/utils.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/wkhtmltopdf/utils.py b/wkhtmltopdf/utils.py index d0475c4..03a5f82 100644 --- a/wkhtmltopdf/utils.py +++ b/wkhtmltopdf/utils.py @@ -19,6 +19,8 @@ def _options_to_args(**options): flags = [] for name in sorted(options): value = options[name] + if value is None: + continue flags.append('--' + name.replace('_', '-')) if value is not True: flags.append(unicode(value)) @@ -38,11 +40,17 @@ def wkhtmltopdf(pages, output=None, **kwargs): {'footer_html': 'http://example.com/foot.html'} becomes '--footer-html http://example.com/foot.html' + Where there is no value passed, use True. e.g.: {'disable_javascript': True} becomes: '--disable-javascript' + To disable a default option, use None. e.g: + {'quiet': None'} + becomes: + '' + example usage: wkhtmltopdf(pages=['/tmp/example.html'], dpi=300, |