This article will introduce how to set and delete PowerPoint document properties with the PropertiesApi interface offered by Spire.Cloud.PowePoint API.
Set Document Properties
import spire.cloud.powerpoint.sdk.*;
import spire.cloud.powerpoint.sdk.api.PropertiesApi;
import spire.cloud.powerpoint.sdk.model.*;
public class setPptDocumentProperties {
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 propertiesApi
static PropertiesApi propertiesApi = new PropertiesApi(configuration);
public static void main(String[] args) throws ApiException {
//Specify the name of the input document
String name = "sample.pptx";
//Specify the original password of the input document, set it to null if there's none
String password = null;
//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;
//Set PowerPoint document properties
java.util.ArrayList propertyList = new java.util.ArrayList();
DocumentProperty property1 = new DocumentProperty();
property1.setName("Keywords");
property1.setValue("PowerPoint document properties");
property1.setBuiltIn(false);
propertyList.add(property1);
DocumentProperty property2 = new DocumentProperty();
property2.setName("Author");
property2.setValue("Smith");
property2.setBuiltIn(false);
propertyList.add(property2);
DocumentProperty property3 = new DocumentProperty();
property3.setName("Company");
property3.setValue("E-iceblue Co. Ltd.");
property3.setBuiltIn(false);
propertyList.add(property3);
DocumentProperty property4 = new DocumentProperty();
property4.setName("Title");
property4.setValue("Test Document");
property4.setBuiltIn(false);
propertyList.add(property4);
DocumentProperty property5 = new DocumentProperty();
property5.setName("Subject");
property5.setValue("Set properties");
property5.setBuiltIn(false);
propertyList.add(property5);
DocumentProperties properties = new DocumentProperties();
properties.list(propertyList);
//Set PowerPoint document properties with the setPptDocumentProperties method
propertiesApi.setPptDocumentProperties(name, properties, password, folder, storage);
}
}
Delete Document Properties
import spire.cloud.powerpoint.sdk.*;
import spire.cloud.powerpoint.sdk.api.PropertiesApi;
import spire.cloud.powerpoint.sdk.model.*;
public class deletePptDocumentProperties {
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 propertiesApi
static PropertiesApi propertiesApi = new PropertiesApi(configuration);
public static void main(String[] args) throws ApiException {
//Specify the name of the input ocument
String name = "sample.pptx";
//Specify the original password of the input document, set it to null if there's none
String password = null;
//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;
//Delete document properties with the deletePptDocumentProperties method
propertiesApi.deletePptDocumentProperties(name, password, folder, storage);
}
}