News Category

Java: Add or Remove Digital Signatures in PowerPoint

2021-10-08 08:30:11 Written by  support iceblue
Rate this item
(0 votes)

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 remove all digital signatures using Spire.Presentation for Java.

Installl Spire.Presentation for Java

First of all, you're required to add the Spire.Presentation.jar file as a dependency in your Java program. The JAR file can be downloaded from this link. If you use Maven, you can easily import the JAR file in your application by adding the following code to your project's pom.xml file.

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

Add a Digital Signature to PowerPoint

The following are the steps to add a digital signature to a PowerPoint document.

  • 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.
  • Java
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);
    }
}

Java: Add or Remove Digital Signatures in PowerPoint

Remove all Digital Signaters from PowerPoint

The following are steps to remove all digital signatures from a PowerPoint document.

  • 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.
  • Java
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);
    }
}

Java: Add or Remove Digital Signatures in PowerPoint

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.

Additional Info

  • tutorial_title:
Last modified on Tuesday, 27 September 2022 06:26