Spire.Cloud.Word supports converting Word to PDF, HTML, Image, SVG, XPS and other document formats by using the ConvertApi interface. This article will demonstrate how to convert Word to HTML using Java codes.
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ConvertApi;
public class WordToHTML {
static String appId = "App ID";
static String appKey = "App Key";
static String baseUrl = "https://api.cloudxdocs.com";
//Create a configuration object based on your AppID and AppKey
static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
//Create a ConvertApi instance
static ConvertApi convertApi = new ConvertApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
//Load a Word sample document
String name = "Sample.docx";
//Specify the password of the sample, and it's "null" if nothing
String password = null;
//Specify the folder storing the sample, and it's "null" if nothing
String folder = "input";
//Use the 2G storage provided by E-iceblue, it's "null" by default
String storage = null;
//Save the resulting document to a specified path
String destFolder = "output/convertToHtml.html";
//Call the convertToHtml method to convert Word to Html
convertApi.convertToHtml(name, destFolder, password, folder, storage);
}
}
Output