Add or Remove Digital Signatures in PowerPoint Using Java

Andrew Wilson
2 min readFeb 21, 2022

A digital signature confirms that the document content originates from the signer and has not been changed. In this article, you will learn how to add a digital signature to your PowerPoint documents as well as how to remove all digital signatures 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>

Add a Digital Signature to PowerPoint

  • Create an object of Presentation class.
  • Load the sample PowerPoint document using Presentation.loadFromFile() method.
  • Add a digital signature to the document using Presentation.addDigitalSignature(String pfxPath, String password, String comments, java.util.Date signTime) method.
  • Save the result to a .pptx file using Presentation.saveToFile() method.
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("sample2.pptx");

//Add a digital signature
String pfxPath = "F:\\pfx\\output\\Eric.pfx";
String password = "111";
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);
}
}

Remove all Digital Signaters from PowerPoint

  • Create an object of Presentation class.
  • Load the sample PowerPoint document using Presentation.loadFromFile() method.
  • Determine if the document contains digital signatures using Presentation.isDigitallySigned() method.
  • Remove all signatures using Presentation.removeAllDigitalSignatures() method.
  • Save the result to a .pptx file using Presentation.saveToFile() method.
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\\IdeaProjects\\PPT\\output\\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);
}
}

--

--

Andrew Wilson

Explore C#, Java and Python solutions for processing Word/Excel/PowerPoint/PDF files.