Spire.Cloud.PDF API provides developers with the PdfConvertApi interface to convert PDF to other file formats such as DOC/DOCX/HTML/PCL/PS/SVG/XPS and PNG. This article will demonstrate how to convert PDF to DOC by using Spire.Cloud.PDF API.
import spire.cloud.pdf.sdk.ApiException;
import spire.cloud.pdf.sdk.Configuration;
import spire.cloud.pdf.sdk.api.PdfConvertApi;
public class ConvertPdfToDoc {
static String appId = "APP ID";
static String appKey = "APP Key";
static String baseUrl = "https://api.cloudxdocs.com";
// Create a Configuration object based on App ID, App Key and base Url
static Configuration configuration = new Configuration(appId, appKey, baseUrl);
//Create an instance of PdfConvertApi
static PdfConvertApi pdfConvertApi = new PdfConvertApi(configuration);
public static void main(String[] args) throws ApiException {
//Specify the name of the input PDF document
String name = "E-iceblue.pdf";
//Specify the storage path and name of the generated document
String destFilepath = "output/ToDoc.doc";
//Specify the file format of the generated document
String format = "Doc";
//Specify the folder where the input PDF document is stored, set it to null if there's none
String folder = "input";
//Store the document in the 2G default storage space offered by E-iceblue Cloud
String storage = null;
//Specify the original password of the input document, set it to null if there's none
String password = null;
//Convert PDF document to Word document with the "convert" method
pdfConvertApi.convert(name, destFilepath, format, folder, storage, password);
}
}