使用 Java 编辑 PPTM 属性

构建使用服务器端 API 修改演示文稿文件内置属性与自定义属性的 Java 应用程序。

通过 Java 修改 PPTM 属性

借助 Aspose.Slides for Java ,开发人员可以访问和修改演示文稿的内置属性与自定义属性。使用 Presentation 对象的 getDocumentProperties 方法访问演示文稿文件的 IDocumentProperties 对象。

修改 PPTM 内置属性 - Java

Presentation presentation = new Presentation("Presentation.pptm");
try {
    IDocumentProperties documentProperties = presentation.getDocumentProperties();

    documentProperties.setAuthor("Aspose.Slides for Java");
    documentProperties.setTitle("Modifying Presentation Properties");
    documentProperties.setSubject("Aspose Subject");
    documentProperties.setComments("Aspose Description");
    documentProperties.setManager("Aspose Manager");

    presentation.save("DocProps.pptm", SaveFormat.Pptm);
} finally {
    presentation.dispose();
}

向 PPTM 添加自定义属性 - Java

Presentation presentation = new Presentation();
try {
    IDocumentProperties documentProperties = presentation.getDocumentProperties();

    documentProperties.set_Item("New Custom", 12);
    documentProperties.set_Item("My Name", "Aspose Metadata Editor");
    documentProperties.set_Item("Custom", 124);

    String customPropertyName = documentProperties.getCustomPropertyName(2);
    documentProperties.removeCustomProperty(customPropertyName);

    presentation.save("CustomDemo.pptm", SaveFormat.Pptm);
} finally {
    presentation.dispose();
}

如何在 Java 中查看或编辑 PPTM 元数据

按照以下步骤查看或编辑 PPTM 元数据。

  1. 使用 Presentation 类加载 PPTM 文件。
  2. 调用 getDocumentProperties 方法获取 IDocumentProperties 对象。
  3. 读取或更新 Author、Title、Subject 和 Comments 等内置属性。
  4. 使用 set_Item、getCustomPropertyName 和 removeCustomProperty 访问和修改自定义属性。

基于 Aspose.Slides 构建

在线查看和编辑 PPTM 元数据

免费的 Aspose.Slides Metadata 应用基于 Aspose.Slides for Java 构建,与上方代码使用的是同一 API。打开它,看看 API 能如何处理您自己的 PPTM 文件。

  • 在浏览器中运行,无需安装任何软件。
  • 在编写代码之前,先看看 Aspose.Slides 如何读写属性。
  • 查看和编辑 PPTM 文件的内置属性与自定义属性。
  • 保存并下载更新后的文件。

其他支持的元数据格式

使用 Java,还可以管理以下格式的元数据。