jarrekk / imgkit

🌁 Wkhtmltoimage python wrapper to convert HTML to image
MIT License
802 stars 73 forks source link

How to set options for wkhtmltopdf in imgkit options? #87

Closed PankajSavaliya closed 1 year ago

PankajSavaliya commented 1 year ago

I have read the document, and there is only described, but not with the sample, and it's also confusing for putting the option for wkhtmltopdf in the same options of imagekit

You can find all wkhtmltoimage options by type wkhtmltoimage command or visit this Manual. You can drop '--' in option name. If option without value, use None, False or '' for dict value:. For repeatable options (incl. allow, cookie, custom-header, post, postfile, run-script, replace) you may use a list or a tuple. With options that need multiple values (e.g. --custom-header Authorization secret) we may use a 2-tuple (see example below).

options = {
    'format': 'png',
    'crop-h': '3',
    'crop-w': '3',
    'crop-x': '3',
    'crop-y': '3',
    'encoding': "UTF-8",
    'custom-header' : [
        ('Accept-Encoding', 'gzip')
    ]
    'cookie': [
        ('cookie-name1', 'cookie-value1'),
        ('cookie-name2', 'cookie-value2'),
    ],
    'no-outline': None
}

imgkit.from_url('http://google.com', 'out.png', options=options)
jarrekk commented 1 year ago

the code is the sample. :)