Recently any generated pdf contains a 50% wide column containing:
You are currently using a browser that is no longer 100% supported. It can cause display
problems.
Please upgrade your browser.
Some alternatives: Firefox, Chrome.
Any ideas where I should start investigating?
I searched for some obvious commandline arguments in the wkhtmltopdf manual to no avail
Environment: Arch Linux, Python pdfkit, Firefox, https://aur.archlinux.org/packages/wkhtmltopdf-static
This message isn't coming from wkhtmltopdf
, it's coming from the website you are trying to PDF. That website is sniffing the wkhtmltopdf
browser's user-agent, and conditionally displaying that message.
Websites sometimes do this because they are written & tested with newer ES6 JavaScript and CSS3 features, without polyfills for older browser versions.
wkthtmltopdf
is basically a very old version of Chrome, which doesn't support all modern CSS & JS features, so it's getting this message.
Because wkhtmltopdf
is based off of the open-source version of Chromium before the license changed, it will likely never be updated. The Wkthtmltopdf GitHub page even shows that it is now archived, and no longer getting updates.
However, if the PDFs are otherwise looking pretty good, you have 3 options (I think).
Disable the browser check when requesting the PDF version of the page (either with a param like ?pdf=true
or by checking the user-agent header). This only works if you can change the code on the server.
Add some custom JavaScript to find the banner message and remove it from the DOM before rendering the PDF
You can do this by passing something like this argument to wkhtmltopdf
:
--run-script "document.getElementById('banner-warning').remove()"
You can do this by passing something like these arguments to wkhtmltopdf
:
--custom-header "User-Agent" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36" --custom-header-propagation
There might be other options of interest to you in the wkhtmltopdf documentation.