Skip to content

Latest commit

 

History

History
 
 

html2pdf

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Html2Pdf Converter

Installation

  1. Install python-pdfkit:
$ pip install pdfkit  (or pip3 for python3)

or from requirements.txt

$ pip install -r requirements.txt  (or pip3 for python3)
  1. Install wkhtmltopdf:
  • Debian/Ubuntu:
$ sudo apt-get install wkhtmltopdf
  • macOS:
$ brew install caskroom/cask/wkhtmltopdf

Usage

For simple tasks:

python html2pdf.py 'google.com' (for python3)

You can pass a list with multiple URLs or files:

python html2pdf.py 'google.com' 'yandex.ru' 'engadget.com' (for python3)

Also you can pass an opened file.

Troubleshooting

  • IOError: 'No wkhtmltopdf executable found':

    Make sure that you have wkhtmltopdf in your $PATH or set via custom configuration (see preceding section). where wkhtmltopdf in Windows or which wkhtmltopdf on Linux should return actual path to binary.

  • IOError: 'Command Failed'

    This error means that PDFKit was unable to process an input. You can try to directly run a command from error message and see what error caused failure (on some wkhtmltopdf versions this can be caused by segmentation faults)