原創|使用教程|編輯:張瑩心|2021-10-09 10:47:17.500|閱讀 715 次
概述:在本文中,您將學習如何使用Spire.Presentation for Java向 PowerPoint 文檔添加數字簽名以及刪除所有數字簽名。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Spire.Presentation for Java 專業的 PowerPoint API,它允許開發人員在 Java 應用程序中創建、讀取、寫入、轉換和保存 PowerPoint 文檔,而無需安裝 Microsoft 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>//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 文檔添加數字簽名的步驟。
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); } }
以下是從 PowerPoint 文檔中刪除所有數字簽名的步驟。
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); } }
慧都是E-iceblue官方友好合作伙伴,如果您對spire.Presentation感興趣,可以了解具體授權價格和使用機制。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn