PDF to HTML Converter

Convert PDF to HTML using Java

One of the defacto standards for information and data sharing over the internet is PDF. The reason for its popularity is that it maintains the layout and fidelity of document when viewed on any platform including Desktop or mobile. However, in order to view the these files, you need to use PDF viewer application. However, a simple workaround is to convert PDF to HTML and easily load the HTML in web browser. So in this article, we are going to further discuss the details on how to develop PDF to HTML converter using REST API.

SXC to Excel Conversion API

In order to create, manipulate and transform PDF files to other formats, please try using Aspose.PDF Cloud SDK for Java. Now in order to use the SDK, please add the following information in pom.xml of maven build type project.



Now that Aspose.PDF Cloud SDK for Java reference is added in your project, the next step is to create a free account over Aspose Cloud. Login using newly created account and lookup/create Client ID and Client Secret at Cloud Dashboard. These details are required in subsequent sections.

PDF to HTML Converter in Java

Let’s discuss the details on how to develop PDF to HTML converter using Java Cloud SDK. Please note that in following code snippet, very basic parameters are used during the conversion operation but we highly recommend visiting API Reference section for the list of all supported parameters as well as their related description.

  • First we need to create a PdfApi object while providing ClientID and Client secret as arguments
  • Secondly, load the input PDF file using File instance
  • Thirdly, upload the input PDF to cloud storage using uploadFile(…) method
  • Since we only need to convert second page of PDF, so we are providing 2nd page value in List object
  • Now call the putPdfInStorageToHtml(…) method requiring input PDF, name of resultant HTML and various other conversion paramets
PDF to HTML Converter

Image1:- PDF to HTML Conversion Preview

The sample PDF file used in above example can be downloaded from PdfWithScreenAnnotations.pdf

Convert PDF to HTML using cURL Commands

The cURL commands are also one of the convenient ways for accessing REST APIs through command line terminal. Now the pre-requisite for this approach is the generation of JWT access token (based on client credentials) while executing the following command.

curl -v "https://api.aspose.cloud/connect/token" \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Once we have the JWT token, we need to execute the following command to convert PDF to HTML. The resultant HTML is saved as Zip archive on Cloud storage.

curl -v -X PUT "https://api.aspose.cloud/v3.0/pdf/input.pdf/convert/html?outPath=resultant.zip&documentType=Html5&fixedLayout=false&splitCssIntoPages=false&splitIntoPages=false&explicitListOfSavedPages=2&fontSavingMode=AlwaysSaveAsTTF&partsEmbeddingMode=EmbedAllIntoHtml&rasterImagesSavingMode=AsEmbeddedPartsOfPngPageBackground&outputFormat=Zip" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>"


We have learned the steps to develop PDF to HTML converter using Java Cloud SDK. So either we can use Jave code snippet to convert PDF to HTML or we can use the cULR commands to convert PDF to HTML5. In case you want to make any changes to the source code of Java Cloud SDK, the complete source code can be downloaded from GitHub. You may consider approaching us for a quick resolution of issues via free product support forum.

We highly recommend visiting the following links to learn more about: