国产PPT格式控件Spire.Presentation功能演示:在Java中添加或删除数字签名

在本文中,您将学习如何使用Spire.Presentation for Java向 PowerPoint 文档添加数字签名以及删除所有数字签名。

Spire.Presentation for Java 专业的 PowerPoint API,它允许开发人员在 Java 应用程序中创建、读取、写入、转换和保存 PowerPoint 文档,而无需安装 Microsoft PowerPoint。

点击此处下载最新版测试。

这么优秀的国产工具怎能错过呢!


一个数字签名,从签名文档内容起源,并没有改变确认。在本文中,您将学习如何使用Spire.Presentation for Java向 PowerPoint 文档添加数字签名以及删除所有数字签名。

安装 Spire.Presentation for Java

首先,您需要在 Java 程序中添加 Spire.Presentation.jar 文件作为依赖项。JAR 文件可以从此链接下载。如果您使用 Maven,则可以通过将以下代码添加到项目的 pom.xml 文件中,轻松地在应用程序中导入 JAR 文件。

<repositories>    <repository>        <id>com.e-iceblue</id>        <name>e-iceblue</name>        <url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>    </repository></repositories><dependencies>    <dependency>        <groupId>e-iceblue</groupId>        <artifactId>spire.presentation</artifactId>        <version>4.9.2</version>    </dependency></dependencies>

向 PowerPoint 添加数字签名

以下是向 PowerPoint 文档添加数字签名的步骤。

  • 创建Presentation类的对象。
  • 使用Presentation.loadFromFile()方法加载示例 PowerPoint 文档。
  • 使用Presentation.addDigitalSignature(String pfxPath, String password, String comments, java.util.Date signTime))方法向文档添加数字签名。
  • 使用Presentation.saveToFile()方法将结果保存到 .pptx 文件。
import com.spire.presentation.FileFormat;import com.spire.presentation.Presentation;import java.util.Date;public class AddDigitalSignature {    public static void main(String[] args) throws Exception {        //Create a Presentation object        Presentation presentation = new Presentation();        //Load the sample PowerPoint document        presentation.loadFromFile("C:\Users\Administrator\Desktop\sample.pptx");        //Add a digital signature        String pfxPath = "C:\Users\Administrator\Desktop\MyCertificate.pfx";        String password = "e-iceblue";        String comment = "Modification is not allowed";        presentation.addDigitalSignature(pfxPath,password,comment,new Date());        //Save the result to file        presentation.saveToFile("output/AddDigitalSignature.pptx", FileFormat.PPTX_2013);    }}

国产PPT格式控件Spire.Presentation功能演示:在Java中添加或删除数字签名从 PowerPoint 中删除所有数字签名者

以下是从 PowerPoint 文档中删除所有数字签名的步骤。

  • 创建Presentation类的对象。
  • 使用Presentation.loadFromFile()方法加载示例 PowerPoint 文档。
  • 使用Presentation.isDigitallySigned( ) 方法确定文档是否包含数字签名。
  • 使用Presentation.removeAllDigitalSignatures()方法删除所有签名。
  • 使用Presentation.saveToFile()方法将结果保存到 .pptx 文件。
import com.spire.presentation.FileFormat;import com.spire.presentation.Presentation;public class RemoveDigitalSignature {    public static void main(String[] args) throws Exception {        //Create a Presentation object        Presentation presentation = new Presentation();        //Load the sample PowerPoint document        presentation.loadFromFile("C:\Users\Administrator\Desktop\AddDigitalSignature.pptx");        //Determine if the document is digitally signed        if (presentation.isDigitallySigned() == true)        {            //Remove all digital signatures            presentation.removeAllDigitalSignatures();        }        //Save the result to file        presentation.saveToFile("output/RemoveDigitalSignature.pptx", FileFormat.PPTX_2013);    }}

国产PPT格式控件Spire.Presentation功能演示:在Java中添加或删除数字签名


是E-iceblue官方友好合作伙伴,如果您对spire.Presentation感兴趣,可以联系在线客服了解具体授权价格和使用机制。
标签:

来源:慧都

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2021年9月6日
下一篇 2021年9月6日

相关推荐

发表回复

登录后才能评论