Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options to set cookies #47

Closed
wants to merge 2 commits into from
Closed

Conversation

romanseidl
Copy link

Wkhtmltopdf allows for cookies to be set. To set multiple cookes the '--cokies' parameter must be repeated, so the options dict does not work for setting multiple cookies.

I introduced a 'cookies' parameter where you can set a dict of cookies.

Usage example / Test:

import pdfkit

cookies = {'a': 'b', 'b':'c'}
pdfkit.from_url("http://www.html-kit.com/tools/cookietester/", "cookies.pdf", cookies=cookies, configuration=pdfkit.configuration(wkhtmltopdf='./wkhtmltox/bin/wkhtmltopdf'))

Usage example / Test:
--------------------------------

import pdfkit

cookies = {'a': 'b', 'b':'c'}
pdfkit.from_url("http://www.html-kit.com/tools/cookietester/", "cookies.pdf", cookies=cookies, configuration=pdfkit.configuration(wkhtmltopdf='./wkhtmltox/bin/wkhtmltopdf'))
@alanhamlett
Copy link
Collaborator

alanhamlett commented May 4, 2017

This looks great! Can you rebase your fork and fix the merge conflicts? Also some tests?

@JazzCore
Copy link
Owner

Cookies shoud now work in master, example from README:

options = {
    'page-size': 'Letter',
    'margin-top': '0.75in',
    'margin-right': '0.75in',
    'margin-bottom': '0.75in',
    'margin-left': '0.75in',
    'encoding': "UTF-8",
    'custom-header': [
        ('Accept-Encoding', 'gzip')
    ],
    'cookie': [
        ('cookie-name1', 'cookie-value1'),
        ('cookie-name2', 'cookie-value2'),
    ],
    'no-outline': None
}

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

@JazzCore JazzCore closed this Mar 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants