Welcome folks today in this blog post we will be converting
html files to pdf using
pdfkit library. For this purpose we will be using python. All the full source code of the application is shown below.
In order to get started we need to install the following library by using the
pip install pdfkit
After installing this library you need to install
wkhtmltopdf application from their official website specially if you are on windows
If you are
linux you will use this command to install this software as shown below
sudo apt-get install wkhtmltopdf
Now after installing in windows you need to set the
path variable like this. First of all we will find the full path of the
wkhtmltopdf inside program files just copy this path and then add this to system
path variable as shown in the below figure.
After setting the path variable just create an
app.py file and copy paste the following code
So here we are converting the
out.pdf so we are taking the local html file and then this python script converts the html file to pdf files using pdfkit library as shown below.
After this we will be converting the
website url to pdf document using
pdfkit in the below example