In this post we will demonstrate how to use the python client library for Api2Pdf.com to generate PDFs from HTML, URLs, Word files, Excel, Powerpoint, etc. You can also merge two or more PDFs together. Here are the steps:
Acquire API Key
- Create an account and login at portal.api2pdf.com
- Add a balance to your account (no monthly commitment, sign up with as little as $1)
- Create an application and grab your API Key
Install the Client
Run the pip command for installing the client
pip install api2pdf
Initialize the Client
All usage starts by calling the import command and initializing the client by passing your API key as a parameter to the constructor.
from api2pdf import Api2Pdf a2p_client = Api2Pdf('YOUR-API-KEY')
Once you initialize the client, you can make calls like so:
api_response = a2p_client.HeadlessChrome.convert_from_html('<p>Hello, World</p>') print(api_response.result)
That’s all there is to it. If you want to see more samples on how to generate PDFs in python, hop on over to the github repo to see its full documentation.