First, you have to use static build of
wkhtmltopdf because it contains a patched version of Qt. THIS is very important to benefit from real-world use case as clickable hyperlinks.
Mac users: the
homebrew package is not sufficient. Use the
.dmg file and then
sudo ln -s /Applications/wkhtmltopdf.app/Contents/MacOS/wkhtmltopdf /usr/bin/wkhtmltopdf
So far so good, the command to convert a Webpage to PDF is simple
wkhtmltopdf http://eepurl.com/sjd5r ~/Desktop/dotjs-announce.pdf
One problem: we have useless stuff on board. No nice to distribute that.
We have the ability to pass extra script to the remote URL before the rendering.
This is script you'll have to pass to the
--run-script argument as a string:
//Remove topbar and any stuff located in a .footer class (like MailChimp badge etc.)
//Images wrapped in hyperlink are clickable at their full height
el.parentNode.style.height = el.height || 'auto';
el.parentNode.style.display = 'inline-block';
//Removes the top border (used by #awesomewrap)
document.querySelector('html').style.border = 'none !important';
The best way is to load the file from your build script, removing
\n chars and safely escape chars.
So the final stuff
wkhtmltopdf --run-script "`cat /path/to/above/script.js | tr '\n' ' '`" http://eepurl.com/sjd5r ~/Desktop/dotjs-announce.pdf