Skip to content

Instantly share code, notes, and snippets.

@e96031413
Created January 1, 2020 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e96031413/55448ee37c0843b23a6259a9e9375982 to your computer and use it in GitHub Desktop.
Save e96031413/55448ee37c0843b23a6259a9e9375982 to your computer and use it in GitHub Desktop.
how to convert html files into a single pdf
import glob,os
import pdfkit #pip install pdfkit
path = r"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe"
config = pdfkit.configuration(wkhtmltopdf=path)
newList=[]
for filename in glob.iglob(os.path.join('*.html')):
newList.append(filename)
pdfkit.from_file(newList, 'out.pdf', configuration=config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment