Webpage text-only into PDF with Python PDFkit

Viewed 16

I am trying to convert a large section of a website into a pdf. I can convert one page with pdfkit, but I do not want the images on the website, just the text. Is there a way to do this with pdfkit? I have been searching google for the last half hour looking for a solution, but can only find information about getting pictures, not excluding them.

Thank you for your help!

1 Answers

This information can be found in the documentation for "wkhtmltopdf". This tool has a --no-images option.

The PyPI page for pdfkit explains how to set options when using the Python package.

So this is what you are looking for:

import pdfkit
options = {
    'no-images':True
}
pdfkit.from_url('https://www.google.com/','out.pdf',options=options)
Related