def wkhtmltopdf(pages, output=None, **kwargs):
if isinstance(pages, six.string_types):<EOL><INDENT>pages = [pages]<EOL><DEDENT>if output is None:<EOL><INDENT>output = '<STR_LIT:->'<EOL><DEDENT>has_cover = kwargs.pop('<STR_LIT>', False)<EOL>options = getattr(settings, '<STR_LIT>', None)<EOL>if options is None:<EOL><INDENT>options = {'<STR_LIT>': True}<EOL><DEDENT>else:<EOL><INDENT>options = copy(options)<EOL><DEDENT>options.update(kwargs)<EOL>options.setdefault('<STR_LIT>', '<STR_LIT:utf8>')<EOL>env = getattr(settings, '<STR_LIT>', None)<EOL>if env is not None:<EOL><INDENT>env = dict(os.environ, **env)<EOL><DEDENT>cmd = '<STR_LIT>'<EOL>cmd = getattr(settings, cmd, os.environ.get(cmd, '<STR_LIT>'))<EOL>if has_cover:<EOL><INDENT>pages.insert(<NUM_LIT:0>, '<STR_LIT>')<EOL><DEDENT>ck_args = list(chain(shlex.split(cmd),<EOL>_options_to_args(**options),<EOL>list(pages),<EOL>[output]))<EOL>ck_kwargs = {'<STR_LIT>': env}<EOL>try:<EOL><INDENT>i = sys.stderr.fileno()<EOL>ck_kwargs['<STR_LIT>'] = sys.stderr<EOL><DEDENT>except (AttributeError, IOError):<EOL><INDENT>pass<EOL><DEDENT>return check_output(ck_args, **ck_kwargs)<EOL>
Converts html to PDF using http://wkhtmltopdf.org/.

pages: List of file paths or URLs of the html to be converted.
output: Optional output file path. If None, the output is returned.
**kwargs: Passed to wkhtmltopdf via _extra_args() (See
          https://github.com/antialize/wkhtmltopdf/blob/master/README_WKHTMLTOPDF
          for acceptable args.)
          Kwargs is passed through as arguments. e.g.:
              {'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,
                orientation='Landscape',
                disable_javascript=True)