3

I am trying to convert an HTML web page using wkhtmltopdf API and pdfkit library. But when I am entering the URL of any web page it is showing me this error.

Traceback (most recent call last):
 File "c:\\Users\\Fai\\Desktop\\doc\\convert.py", line 13, in \<module\>
  pdfkit.from_url("www.imdb.com/chart/top/", "imdb.pdf", configuration=config)
 File "C:\\Python\\Python310\\lib\\site-packages\\pdfkit\\api.py", line 27, in from_url
  return r.to_pdf(output_path)
 File "C:\\Python\\Python310\\lib\\site-packages\\pdfkit\\pdfkit.py", line 201, in to_pdf
 File "c:\\Users\\Fai\\Desktop\\doc\\convert.py", line 13, in \<module\>
  pdfkit.from_url("www.imdb.com", "imdb.pdf", configuration=config)
 File "C:\\Python\\Python310\\lib\\site-packages\\pdfkit\\api.py", line 27, in from_url
  return r.to_pdf(output_path)
 File "C:\\Python\\Python310\\lib\\site-packages\\pdfkit\\pdfkit.py", line 201, in to_pdf
  self.handle_error(exit_code, stderr)
 File "C:\\Python\\Python310\\lib\\site-packages\\pdfkit\\pdfkit.py", line 155, in handle_error
  raise IOError('wkhtmltopdf reported an error:\\n' + stderr)
OSError: wkhtmltopdf reported an error:
Error: Failed loading page https://www.google.com (sometimes it will work just to ignore this error with --load-error-handling ignore)
Exit with code 1 due to network error: SslHandshakeFailedError

My code:

import os
from docx2pdf import convert
import pdfkit

path_wkhtmltopdf = r'C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe'
config = pdfkit.configuration(wkhtmltopdf=path_wkhtmltopdf)

PATH = "C:/Users/Fai/Desktop/doc"
os.chdir(PATH)

list_dir = os.listdir()

pdfkit.from_url("www.imdb.com", "imdb.pdf", configuration=config)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.