

* ``meta_tag_prefix`` - the prefix for ``pdfkit`` specific meta tags - by default this is ``pdfkit-``Įxample - for when ``wkhtmltopdf`` is not on ``$PATH``::Ĭonfig = nfiguration(wkhtmltopdf='/opt/bin/wkhtmltopdf') By default ``pdfkit`` will attempt to locate this using ``which`` (on UNIX type systems) or ``where`` (on Windows). * ``wkhtmltopdf`` - the location of the ``wkhtmltopdf`` binary. It takes the configuration options as initial paramaters. This should be an instance of ``nfiguration()`` API call. om_string(body, 'out.pdf') #with -page-size=Legal and -orientation=LandscapeĮach API call takes an optional configuration paramater. You can also pass any options through meta tags in your HTML::

om_file('file.html', options=options, css=css) You should try *-user-style-sheet* option first. **Warning** This is a workaround for `this bug `_ in wkhtmltopdf. You can specify external CSS files when converting files or strings using *css* option. om_file('file.html', options=options, toc=toc, cover=cover, cover_first=True) om_file('file.html', options=options, toc=toc, cover=cover) If you need cover before TOC, use ``cover_first`` option:: om_url('', 'out.pdf', verbose=True)ĭue to wkhtmltopdf command syntax, **TOC** and **Cover** options must be specified separately. If need to get ``wkhtmltopdf`` output you should pass ``verbose=True`` to API calls:: om_url('', 'out.pdf', options=options)īy default, PDFKit will run ``wkhtmltopdf`` with ``quiet`` option turned on, since in most cases output is not needed and can cause excessive memory usage and corrupted results. custom-header Authorization secret) we may use a 2-tuple (see example below). With option that need multiple values (e.g. allow, cookie, custom-header, post, postfile, run-script, replace) you may use a list or a tuple. If option without value, use *None, False* or *''* for dict value. You can specify all wkhtmltopdf `options `_.
#Pdfkit options pdf
# Without output_path, PDF is returned for assigning to a variable If you wish to further process generated PDF, you can read it to a variable:: You can pass a list with multiple URLs or files::

#Pdfkit options windows
* Windows and other options: check wkhtmltopdf `homepage `_ for binary installers
#Pdfkit options install
To use this options you should install static binary from `wkhtmltopdf `_ site or you can use `this script `_. **Warning!** Version in debian/ubuntu repos have reduced functionality (because it compiled without the wkhtmltopdf QT patches), such as adding outlines, headers, footers, TOC etc. $ pip install pdfkit (or pip3 for python3) This is adapted version of `ruby PDFKit `_ library, so big thanks to them! Python 2 and 3 wrapper for wkhtmltopdf utility to convert HTML to PDF using Webkit.
