Converting PDF documents to HTML format is quite essential, especially when we need to display the content online, improving accessibility, and enabling easy content reuse in web applications. In this article, you will learn how to convert PDF to HTML using GroupDocs.Conversion Cloud SDK for .NET, preserving document layout, images, and formatting.

This article covers the following topics:

PDF to HTML Conversion API

GroupDocs.Conversion Cloud SDK for .NET offers a robust API to convert PDF documents to HTML with high accuracy. It allows you to customize output HTML, define page ranges, and control image quality, making it ideal for integrating document-to-web workflows in your .NET applications.

Installation

Install the SDK via NuGet Package Manager:

Install-Package GroupDocs.Conversion-Cloud -Version 24.2.0

Or using .NET CLI:

dotnet add package GroupDocs.Conversion-Cloud --version 24.2.0

Now, you need to obtain your personalized Client ID and Client Secret from the Aspose Cloud Dashboard to authenticate API requests.

Convert PDF to HTML in C# (.NET)

Here’s a step-by-step C# example to convert a PDF to HTML:

  1. Configure API Credentials:
var config = new Configuration
{
    ClientId = "YOUR_CLIENT_ID",
    ClientSecret = "YOUR_CLIENT_SECRET"
};

var convertApi = new ConvertApi(config);
var fileApi = new FileApi(config);
  1. Upload PDF file to the Cloud Storage:
using (var fileStream = File.OpenRead("sample.pdf"))
{
    var uploadRequest = new UploadFileRequest("sample.pdf", fileStream);
    fileApi.UploadFile(uploadRequest);
}
  1. Set Conversion Settings:
var settings = new ConvertSettings
{
    FilePath = "sample.pdf",
    Format = "html",
    OutputPath = "converted/resultant.html"
};
  1. Perform PDF to HTML Conversion:
var request = new ConvertDocumentRequest(settings);
convertApi.ConvertDocument(request);
free pdf to html online

Image:- A preview of PDF to HTML conversion.

  • The sample PDF used in the above example can be downloaded from input.pdf.

Convert PDF to Web Page using cURL

You can also use the GroupDocs.Conversion Cloud REST API with cURL for quick command-line conversion.

  • Generate JWT Access Token with your credentials.
  • Run the following cURL command:
curl -v "https://api.groupdocs.cloud/v2.0/conversion" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "{  \"StorageName\": \"default\",  \"FilePath\": \"{sourcePDF}\",  \"Format\": \"html\",  \"OutputPath\": \"{resultantFile}\"}"
  • Execute the following command to save the HTML on local drive:
curl -v "https://api.groupdocs.cloud/v2.0/conversion" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "{  \"StorageName\": \"default\",  \"FilePath\": \"{sourceFile}\",  \"Format\": \"html\"}" \
-o "{resultantFile}"
  • Replace: sourceFile, resultantFile, and accessToken with actual values.

Try Our Free PDF to HTML Converter

Try our free PDF to HTML Converter App to see the conversion quality before integrating it into your application.

Free PDF to HTML converter online

Conclusion

Using GroupDocs.Conversion Cloud SDK for .NET, you can easily integrate PDF to HTML conversion into your .NET projects, enabling high-quality, web-compatible outputs while preserving formatting. Whether you use the SDK in C# or make direct REST API calls via cURL, the process is straightforward and highly customizable.

We highly recommend exploring the following articles: