HTML files are usually the basic building block of the websites. HTML file format lets you manipulate or organize text, images, tables or any other page contents. Modern web applications generate reports or information in HTML format because almost all devices support this format without needing any additional or complex configuration. However, often we need to protect a document from modifications by means of document privileges or digital signing. You may also need to archive data for longer periods of time. In such cases, you can convert HTML files to PDF documents. There could be many other reasons to convert HTML files to PDF. Here we will be discussing this use case in connection with Aspose.HTML Cloud APIs.

Aspose.HTML Cloud API for HTML to PDF Conversion

Aspose.HTML Cloud is a REST API that allows you to convert or manipulate HTML documents and several other Supported File Formats. You can use it on any platform you may plan to work with, because it can be used with cURL commands or SDKs including PHP, Ruby, Python, Node.js and many others. You only need to sign up for free and test the API in its full capacity. We have already compiled all the necessary information about Creating and Managing accounts in the documentation article.

Convert HTML files to PDF

Here we will be discussing two popular but different use cases of HTML to PDF conversion using cURL. First of all, let’s consider the conversion of HTML file to PDF where HTML file exists on your local disk and the result PDF will be saved in your storage.

  1. Get your App Key and App SID after signing up
  2. Get JSON Web Token
  3. Call the API
  4. Generated PDF file will be saved in a specified folder on the Storage

Below code snippet shows all these steps and converts the HTML file to PDF:

Input HTML file displayed by browser (Google Chrome)

HTML to PDF rendering

Output PDF file generated by Aspose.HTML Cloud API

PDF output

Likewise, you can also convert HTML to PDF by using a URL. In response to your request, a PDF file will be received which you may save in your local file system. Below are the steps for converting a web page to PDF by specifying the URL.

  1. Get your App Key and App SID after signing up
  2. Get JSON Web Token
  3. Call the API where you need to pass the URL as parameter
  4. Generated PDF file will be saved in your local file system

Following code snippet follows these steps and can simply generate a PDF document:

Webpage displayed by browser (Google Chrome)

Source HTML file

Output PDF file generated by Aspose.HTML Cloud


As you can notice the generated PDF file is a true depiction of WYSIWYG rendering. The API performs high fidelity rendering thus it could be a perfect candidate to be integrated into your applications. Feel free to test the APIs prior to purchasing it and we would love to hear your concerns, questions or suggestions via our Free Support Forums.

Related Post: