top | item 39268147

(no title)

pavs | 2 years ago

like this:

  sudo apt install pandoc wkhtmltopdf
  npm install -g readability-cli
  pandoc -s https://www.paulgraham.com/avg.html -o output.html && readable output.html -o readable.html && wkhtmltopdf readable.html output.pdf &&  open output.pdf
going even further using bash script to prompt for url.

  #!/bin/bash

  # Prompt the user for a URL
  read -p "Enter the URL: " URL

  # Use the URL in the pandoc command
  pandoc -s $url -o output.html && readable output.html -o readable.html && wkhtmltopdf readable.html output.pdf && open output.pdf


  chmod +x web2pdf.sh
  # add an alias to bashrc
  alias web2pdf='/path/to/your/web2pdf.sh'
  source ~/.bashrc

discuss

order

bananskalhalk|2 years ago

Or you could just import weasyprint and readability in python!

Which is pretty much what OP did, with a few nice additions like nice output and some custom css and fonts. Which is nice and OP hope brings value to people.

If you add a few printf:s and include a nice template for pandoc* it would be more along the same thing.

*) Neither pandoc, wkhtmlpdf or weasyprint have (in my opinion) bad default templates.

natrys|2 years ago

Pandoc can also output to pdf if you have latex installed. You can use tectonic if you want a single binary solution than a full latex toolchain, it downloads necessary packages on the fly.