Verify if a PowerPoint Document is Digitally Signed Using Java
PowerPoint documents signed with digital signatures can help recipients check if they have been altered since they were signed. If any changes are made, the signatures will become invalid immediately. Therefore, before you edit a PowerPoint document, you should check if it has been digitally signed or not. In this article, you will learn how to achieve this task programmatically in Java using Free Spire.Presentation for Java.
Import JAR Dependency (2 Methods)
● Download the free library and unzip it, and then add the Spire.Presentation.jar file to your project as dependency.
● You can also add the jar dependency to your maven project by adding the following configurations to the pom.xml.
<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.free</artifactId>
<version>5.1.0</version>
</dependency>
</dependencies>
Steps and Sample Code
- Create a Presentation instance.
- Load a PowerPoint document using Presentation.loadFromFile() method.
- Detect if the document is digitally signed or not using Presentation.isDigitallySigned() method.
import com.spire.presentation.Presentation;
public class VerifyIfPPTisDigitallySigned {
public static void main(String []args) throws Exception {
//Create a Presentation instance
Presentation ppt = new Presentation();
//Load a PowerPoint document
ppt.loadFromFile("DigitalSignature.pptx");
//Verify if the document is digitally signed or not
if (ppt.isDigitallySigned()) {
System.out.println("This document is digitally signed");
} else {
System.out.println("This document is not digitally signed");
}
}
}
