Create PDF Files – Step-by-Step Guide
- Add Files
- Install Requests Module
- Your API Key
- HTML Template and Destination File Name
- Run Program
- Demo
In this demonstration, we will show you the best way to create PDF files in Python. We will use this /v1/pdf/convert/from/html
endpoint. Below is the sample template and the created PDF file.

Step 1: Add Files
First, add your files to the Python program folder. You can download our sample file and python code here.
Step 2: Install Requests Module
Next, if you haven’t yet. Then, install the requests module by typing the python -m pip install requests
and hitting enter to install the pip requests.
Step 3: Your API Key
Now, let’s add your PDF.co API Key in line 7. You can get the API Key in your PDF.co dashboard.
Step 4: HTML Template and Destination File Name
In lines 13 and 18, enter the template name and the PDF output name.
Step 5: Run Program
We are now ready to run the Python program and check on your folder to see the result.
Step 6: Demo
Here’s the HTML to PDF Web API in action.

In this tutorial, you learned the best way to create PDF files in Python. You learned how to use the HTML to PDF Web API to create PDF files. You also learned how to install the requests module.