Spire.Cloud.Word Java SDK provides the WordDocumentApi interface to support creating a word document and getting the objects of documents. The article will show you how to create a blank word document using this interface.
Code Snippets
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.WordDocumentApi;
public class CreateWord {
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 WordDocumentApi instance
static WordDocumentApi wordDocumentApi = new WordDocumentApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
//Specify the document format as "docx". It also supports doc, rtf, wordml, docm, dotx, dot, dotm
String fileFormat = "docx";
//name the new document
String name = "newDocument";
//name the folder storing the new document
String destFolder = "output";
//Use the 2G storage provided by E-iceblue, It's null by default
String storage = null;
//Call the wordDocumentApi method to create a blank word document
wordDocumentApi.createDocument(fileFormat, name, destFolder, storage);
}
}
Output