Skip to content

Instantly share code, notes, and snippets.

@jurv
Created February 9, 2017 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jurv/1aad77c50df4e9cacbbed1a285be79dc to your computer and use it in GitHub Desktop.
Save jurv/1aad77c50df4e9cacbbed1a285be79dc to your computer and use it in GitHub Desktop.
Use session with wkhtmltopdf
wget --save-cookies cookies.txt --keep-session-cookies http://my-site.dev/app_dev.php/my/page
# It's possible to add option "--post-data 'user=foo&password=bar' " if you need to
# log in for exemple
# Then retrieve the session ID in cookie.txt
vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64 \
--cookie 'sessionid' 'gfou6ks1lsguuvtk9il2v169n7' \
--cookie 'PHPSESSID' 'gfou6ks1lsguuvtk9il2v169n7' \
--debug-javascript \
--load-error-handling ignore \
--post myform[item][size] xl \
--post myform[item][color] black \
--post myform[item][quantity] 1 \
--post myform[_token] 2O-7Y9_jY6v46dunWno9vdaXJZw5hDiBdudiOegiCa8 \
http://my-site.dev/app_dev.php/my/second/page \
test.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment