Skip to Content

How to create clean & readable pdfs from webpages with the command line

whirlpool's picture

Before

After

Note: Use the latest wkhtmltopdf as the one packaged with Ubuntu Natty doesn't accept Javascript.

"javascript:(function(){ readStyle='style-newspaper'; readSize='size-small'; readMargin='margin-narrow'; _readability_script=document.createElement('SCRIPT'); _readability_script.type='text/javascript'; _readability_css=document.createElement('LINK'); _readability_css.rel='stylesheet'; _readability_css.href='file:///home/username/path/to/readability-0.5.1/css/readability.css'; _readability_css.type='text/css'; _readability_css.media='screen'; _readability_print_css=document.createElement('LINK'); _readability_print_css.rel='stylesheet'; _readability_print_css.href='file:///home/username/path/to/readability-0.5.1/css/readability-print.css'; _readability_print_css.media='print'; _readability_print_css.type='text/css';

It took me a while to discover that wkhtmltopdf expects JS in the command line and not a path to a file.



Dr. Radut | blog