DEV Community

loading...

How to generate PDF from web pages

napolux profile image Francesco Napoletano ・1 min read

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

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

Discussion (0)

pic
Editor guide