Spire.Cloud.PowerPoint offers the DocumentApi interface to convert PPT(X) to other document formats. If you want to convert a whole PowerPoint document to other formats, you only need to run the convertPptToPath method under the DocumentApi interface, while if you need to convert a specified range of slides to other formats, you should use the splitPpt method.
This article will use the convertPptToPath method to convert the whole PowerPoint document as below to PDF.
import spire.cloud.powerpoint.sdk.*;
import spire.cloud.powerpoint.sdk.model.*;
import spire.cloud.powerpoint.sdk.api.DocumentApi;
public class PPTToPDF {
static String appId = "App ID";
static String appKey = "App Key";
static String baseUrl = "https://api.cloudxdocs.com";
//Create a Configuration object based on your App ID and App Key
static Configuration configuration = new Configuration(appId, appKey, baseUrl);
//Initialize the DocumentApi object
static DocumentApi documentApi = new DocumentApi(configuration);
public static void main(String[] args) throws ApiException {
//Load a PowerPoint document
String name = "Sample.pptx";
//Specify the password used to open the sample, and it's null if nothing
String password = null;
//Use the 2G storage provided by E-iceblue Cloud, and it’s null by default
String storage = null;
//Specify the folder storing the sample, and it’s null if nothing
String folder = "input";
//Specify the document format as PDF
String format = ExportFormat.PDF.toString();
//Set the ExportOptions as null
ExportOptions options = null;
//Specify the output path of the resulting file
String destFilePath = "output/PptToPdf.pdf";
//Call the convertPptToPath method to convert PPT to PDF and store it in the specified path
documentApi.convertPptToPath(name, destFilePath, format, options, password, storage, folder);
}
}
Output