Save Webpage to a pdf

Here is a quick one line program that will take any webpage and turn it into a pdf file.

Webpage to pdf in one line.
you will need to install wkhtmltopdf for it to work.

Here is the program.

import pdfkit
pdfkit.from_url(‘http://google.com’, ‘out.pdf’)

Save the above two lines as a .py file

just change the url and the output filename to what you want.

1 Like

Nice little library. There is just no way I can keep track of all the cool python libraries.

-C

I used to hate python. After being in the engineering field for so long and working in a very fast paced research and prototyping industry, I have learned to love it. For rapid prototyping its pretty powerful.