Add or Remove Digital Signatures in PowerPoint Using 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.

<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);
}
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store