关于java:Java-如何将PPT演示文稿标记为最终状态

8次阅读

共计 1366 个字符,预计需要花费 4 分钟才能阅读完成。

前言

在日常操作 PPT 中,当咱们实现编辑,不心愿再对文档有任何其余更改时,可将演示文稿标记为最终状态。本文就将通过 Java 程序来介绍如何对演示文稿进行最终状态标记。

应用工具:Free Spire.Presentation for Java

测试环境:

  • Intellij Idea2019.1
  • JDK 1.8.0
  • Spire.Presentation.jar

Jar 包获取及导入:

办法 1:在官网上下载 Free Spire.Presentation for Java 产品包,解压后将 lib 文件夹下的 Spire.Presentation.jar 手动导入 IDEA 中。

办法 2:通过 Maven 仓库装置导入产品及依赖包。创立一个 Maven 应用程序,在 pom.xml 文件中配置 Maven 仓库门路及指定 Spire.Presentation for Java 的 Maven 依赖。

<repositories>  
<repository>  
<id>com.e-iceblue</id>  
<url>http://repo.e-iceblue.cn/repository/maven-public/</url>  
</repository>  
</repositories>  
<dependencies>  
<dependency>  
<groupId> e-iceblue </groupId>  
<artifactId>spire.presentation.free</artifactId>  
<version>2.6.1</version>  
</dependency>  
</dependencies>

配置实现后,只需点击 ”Import Changes” 即可导入 JAR 包。

代码示例

Free Spire.Presentation for Java 提供了 getDocumentProperty() 办法来获取文档属性,并将 MarkAsFinal 文档属性设置为 ture,以此来将演示文稿标记为最终状态。

import com.spire.presentation.FileFormat;  
import com.spire.presentation.Presentation;  
  
public class MarkAsFinal {public static void main(String[] args) throws Exception {  
        // 加载示例文档  
 Presentation presentation = new Presentation();  
        presentation.loadFromFile("C:UsersTest1DesktopSample.pptx");  
  
        // 设置文档属性 MarkAsFinal 为 true  
 presentation.getDocumentProperty().set("_MarkAsFinal", true);  
  
        // 保存文档  
 presentation.saveToFile("output/MarkasFinal.pptx", FileFormat.PPTX_2010);  
    }  
}

效果图:

总结:

Free Spire.Presentation for Java 仅凭四行代码就实现了将 PPT 演示文稿标记为最终状态这一性能,足以阐明其产品性能及实现成果极佳。除此以外,它还能反对许多 Microsoft Office 所具备的性能,而运行环境无需装置 Microsoft Office。

正文完
 0