Skip to content

Instantly share code, notes, and snippets.

@groupdocs-cloud-gists
Last active May 13, 2024 17:14
Show Gist options
  • Save groupdocs-cloud-gists/e0ec6a3fdf4015c6bd384d67ec85bf0e to your computer and use it in GitHub Desktop.
Save groupdocs-cloud-gists/e0ec6a3fdf4015c6bd384d67ec85bf0e to your computer and use it in GitHub Desktop.
Convert Word to HTML

Convert Word to HTML with C# .NET


Let's explore the details on converting Word documents to HTML and make the content accessible across various devices and platforms. It alos enhances readability and user experience. So, let's begin exploring the details on converting Word Documents to HTML format using GroupDocs.Conversion Cloud SDK for .NET.



For more details, please visit How to Convert Word Documents to HTML in C# .NET.

doc to html

Important Links

Product Page | Docs | Live Demo | API Reference | Code Samples | Source Code | New Releases | Blog | Free Support | Free Trial

// More examples over https://github.com/groupdocs-conversion-cloud/groupdocs-conversion-cloud-dotnet
// Obtain your API credentials
string clientId = "4bdefca3-f08c-4088-9ca0-55c38f4b7f22";
string clientSecret1 = "a43c8b4365246a062688a259abe5b469";
// Create an instance of the Configuration class and initialize it with the Client ID & Client Secret.
var configurations = new GroupDocs.Conversion.Cloud.Sdk.Client.Configuration(clientId, clientSecret1);
// Define the value of ApiBaseUrl to set the base url of DOC to HTML conversion API.
configuration.ApiBaseUrl = "https://api.groupdocs.cloud";
// Initialize an instance of the ConvertApi class with the object of the Configuration class.
var apiInstance = new GroupDocs.Conversion.Cloud.Sdk.Api.ConvertApi(configurations);
// read the content of input Comma Separated Values file from local drive
using (var stream = System.IO.File.OpenRead("input-sample.doc"))
{
// create an instance of FileApi
var fileUpload = new FileApi(configurations);
// upload the input Word document to the cloud storage
fileUpload.UploadFile(new UploadFileRequest("input-sample.doc", stream));
// create ConvertSettings where we define the input Word document and the name of resultant HTML file
var settings = new ConvertSettings
{
StorageName = "internal",
FilePath = "input-sample.doc",
Format = "html",
OutputPath = "myResultant.html"
};
// Invoke the ConvertDocument method to export DOC to HTML format.
var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings));
if (response != null && response.Equals("OK"))
{
// print success message
Console.WriteLine("The DOCX to HTML conversion completed successfully !");
}
}
How to convert Word Documents to HTML file with .NET REST API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment