How to generate PDF from web pages

napolux

Francesco Napoletano

Posted on May 4, 2020

How to generate PDF from web pages

Originally published on my blog

For a little project of mine I had to generate PDF files from a fairly complex HTML web page.

The original page was created in PHP, so I’ve looked at libraries like dompdf and TCPDF I used many years ago. They’re still like 10 years ago… Not working well with CSS3 and tables.

After many tries the only library working fine was WeasyPrint. You can use in your Python projects or from the command line.

weasyprint https://napolux.com output.pdf
Enter fullscreen mode Exit fullscreen mode

Perfect output and small PDF size. Give it a try!

💖 💪 🙅 🚩
napolux
Francesco Napoletano

Posted on May 4, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related