How to add/remove digital signature to PowerPoint document in Java
Tags: ppt, java, digitalsignature, slides
Published: 2021-10-19 03:18:01

---
title: How to add/remove digital signature to PowerPoint document in Java
published: true
description: add digital signature to protect Presentation slides; remove the digital signature from PowerPoint document
tags: ppt,java, digitalsignature, slides

---
<b>Digital signature</b> is a great way to protect the original document has not been changed. Creating digital signature in PowerPoint document becomes one of the most popular way to protect the presentation slides from editing and tampering. Spire.Presentation for java offers Presentation.addDigitalSignature() method and  Presentation.removeAllDigitalSignatures() method to add and remove the digital signature. 

<b>Installl Spire.Presentation for Java</b>

Firstly, we need to add the Spire.Presentation.jar file as a dependency in our Java program. The JAR file can be downloaded from [this link](https://www.e-iceblue.com/Download/presentation-for-java.html). If we use Maven, we can import the JAR file by adding the following code to the project's pom.xml file.
```java
<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>4.9.2</version>
    </dependency>
</dependencies>
```
<b>Add a Digital Signature to PowerPoint</b>

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 document 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("sample.pptx");

        //Add a digital signature
        String pfxPath = "Certificate.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);
    }
}
```
![Add digital signature to PowerPoint](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rn2m5s8ajpikxizzwatt.png)

<b>Remove all Digital Signatures from PowerPoint</b>

We will remove all digital signatures from a PowerPoint document via the following steps:
 * 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("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);
    }
}
```
![Remove digital signature from PowerPoint](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/755mr64f47jghmlki1fa.png)
Besides the digital signature, Spire.Presentation for Java also enables developers to <b>encrypt the PowerPoint files with password, set write protection to protect presentation slides</b>. You could [check the tutorial links for more information](https://www.e-iceblue.com/Tutorials/Java/Spire.Presentation-for-Java/Program-Guide/Spire.Presentation-Program-Guide-Content-for-Java.html). Thanks for your reading.