Metadata-Version: 1.1
Name: pdfkit
Version: 0.2.3
Summary: Wkhtmltopdf python wrapper to convert html to pdf using the webkit rendering engine and qt
Home-page: UNKNOWN
Author: Golovanov Stanislav
Author-email: stgolovanov@gmail.com
License: MIT
Download-URL: https://github.com/JazzCore/python-pdfkit
Description: Python-PDFKit: HTML to PDF wrapper

        ==================================

        

        Python wrapper for wkhtmltopdf utility to convert HTML to PDF using Webkit.

        

        This is adapted version of `ruby python-pdfkit <https://github.com/pdfkit/pdfkit>`_ library, so big thanks to them!

        

        Installation

        ------------

        

        1. Install python-pdfkit:

        

        ::
        

        	$ pip install pdfkit

        

        2. Install wkhtmltopdf:

        

        * Debian/Ubuntu:

        

        ::
        

        	$ sudo apt-get install wkhtmltopdf

        

        * Windows and other options: check wkhtmltopdf `homepage <http://code.google.com/p/wkhtmltopdf/>`_ for binary installers

        

        Usage

        -----

        

        For simple tasks:

        

        ::
        

        	import pdfkit

        

        	pdfkit.from_url('http://google.com', 'out.pdf')

        	pdfkit.from_file('test.html', 'out.pdf')

        	pdfkit.from_string('Hello!', 'out.pdf')

        

        You can pass a list with multiple URLs or files:

        

        ::
        

        	pdfkit.from_url(['google.com', 'yandex.ru', 'engadget.com'], 'out.pdf')

        	pdfkit.from_file(['file1.html', 'file2.html'], 'out.pdf')

        

        You can specify all wkhtmltopdf `options <http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf_0.10.0_rc2-doc.html>`_. You can drop '--' in option name. If option without value, use *None, False* or *''* for dict value:

        

        ::
        

        	options = {

        	    'page-size': 'Letter',

        	    'margin-top': '0.75in',

        	    'margin-right': '0.75in',

        	    'margin-bottom': '0.75in',

        	    'margin-left': '0.75in',

        	    'encoding': "UTF-8",

        	    'no-outline': None

        	}

        

        	pdfkit.from_url('http://google.com', 'out.pdf', options=options)

        

        

        Due to wkhmtltopdf command syntax, **TOC** and **Cover** options must be specified separately:

        

        ::
        

        	toc = {

        	    'xsl-style-sheet': 'toc.xsl'

        	}

        

        	cover = 'cover.html'

        

        	pdfkit.from_file('file.html', options=options, toc=toc, cover=cover)

        

        You can specify external CSS file when converting files or strings using *css* option.

        

        **Warning** This is a workaround for `this bug <http://code.google.com/p/wkhtmltopdf/issues/detail?id=144>`_ in wkhtmltopdf. You should try *--user-style-sheet* option first.

        

        ::
        

        	css = 'example.css'

        

        	pdfkit.from_file('file.html', options=options, css=css)

        

        You can also pass any options through meta tags in your HTML:

        

        ::
        

        	body = """

        	    <html>

        	      <head>

        	        <meta name="pdfkit-page-size" content="Legal"/>

        	        <meta name="pdfkit-orientation" content="Landscape"/>

        	      </head>

        	      Hello World!

        	      </html>

        	    """

        

        	pdfkit.from_string(body, 'out.pdf') #with --page-size=Legal and --orientation=Landscape

        

        Troubleshooting

        ---------------

        

        - ``IOError: 'No wkhtmltopdf executable found'``:

        

          Make sure that you have wkhtmltopdf in your PATH. *where wkhtmltopdf* in Windows or *which wkhtmltopdf* on Linux should return actual path to binary.
Platform: UNKNOWN
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Topic :: Text Processing
Classifier: Topic :: Text Processing :: General
Classifier: Topic :: Text Processing :: Markup
Classifier: Topic :: Text Processing :: Markup :: HTML
Classifier: Topic :: Text Processing :: Markup :: XML
Classifier: Topic :: Utilities
