In this post we will demonstrate how to use the c# / .net 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 nuget command for installing the client
Or if you are using .NET Core, type
dotnet add package Api2Pdf
Initialize the Client
All usage starts by initializing the client by passing your API key as a parameter to the constructor.
var a2pClient = Api2Pdf("YOUR-API-KEY");
Once you initialize the client, you can make calls like so:
var apiResponse = a2pClient.HeadlessChrome.FromHtml("<p>Hello, World</p>"); Console.WriteLine(apiResponse.Pdf); Console.ReadLine();
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.