page 114

A digital signature is a modern alternative to signing documents manually on paper with pen. It uses an advanced mathematical technique to check the authenticity and integrity of digital documents, which guarantees that the contents in a digital document comes from the signer and has not been altered since then. Sometimes PowerPoint documents that contain confidential information may require a signature. In this article, you will learn how to programmatically add or remove digital signatures in PowerPoint using Spire.Presentation for .NET.

Install Spire.Presentation for .NET

To begin with, you need to add the DLL files included in the Spire.Presentation for.NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.

PM> Install-Package Spire.Presentation

Add a Digital Signature to PowerPoint in C# and VB.NET

To add a digital signature, you'll need to have a valid signature certificate first. Then you can digitally sign a PowerPoint document with the certificate using Presentation.AddDigitalSignature (X509Certificate2 certificate, string comments, DateTime signTime) method. The detailed steps are as follows.

  • Create a Presentation instance.
  • Load a sample PowerPoint document using Presentation.LoadFromFile() method.
  • Initializes an instance of X509Certificate2 class with the certificate file name and password.
  • Add a digital signature to the PowerPoint document using Presentation.AddDigitalSignature (X509Certificate2 certificate, string comments, DateTime signTime) method.
  • Save result document using Presentation.SaveToFile() method.
  • C#
  • VB.NET
using Spire.Presentation;
using System;

namespace AddDigitalSignature
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Presentation instance
            Presentation ppt = new Presentation();
			
	    //Load a PowerPoint document
            ppt.LoadFromFile("Input.pptx");

            //Add a digital signature
            ppt.AddDigitalSignature("gary.pfx", "e-iceblue", "test", DateTime.Now);

            //Save the result document
            ppt.SaveToFile("AddDigitalSignature_result.pptx", FileFormat.Pptx2010);
            System.Diagnostics.Process.Start("AddDigitalSignature_result.pptx");

            //Dispose
            ppt.Dispose();			
        }
    }
}

C#/VB.NET: Add or Remove Digital Signatures in PowerPoint

Remove All Digital Signatures from PowerPoint in C# and VB.NET

At some point you may need to remove the digital signatures from a PowerPoint document. Spire.Presentation for .NET provides the Presentation.RemoveAllDigitalSignatures() method to remove all digital signatures at once. The detailed steps are as follows:

  • Create a Presentation instance.
  • Load a sample PowerPoint document using Presentation.LoadFromFile() method.
  • Determine if the document contains digital signatures using Presentation.IsDigitallySigned property.
  • Remove all digital signatures from the document using Presentation.RemoveAllDigitalSignatures() method.
  • Save the result document using Presentation.SaveToFile() method.
  • C#
  • VB.NET
using Spire.Presentation;

namespace RemoveDigitalSignature
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Presentation instance
            Presentation ppt = new Presentation();

            //Load a PowerPoint document 
            ppt.LoadFromFile("AddDigitalSignature.pptx");

            //Detect if the document is digitally signed
            if (ppt.IsDigitallySigned == true)
            {
                //Remove all digital signatures
                ppt.RemoveAllDigitalSignatures();
            }

            //Save the result document
            ppt.SaveToFile("RemoveDigitalSignature.pptx", FileFormat.Pptx2013);

        }
    }
}

C#/VB.NET: 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.

Add image comment to Excel in Java

2021-05-08 03:26:04 Written by Koohji

We have demonstrated how to add and read text comments in Excel in Java applications. This article will show you how to insert image comment to Excel with Spire.XLS for Java.

import com.spire.xls.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.*;

public class Test {
    public static void main(String[] args)throws IOException {
        //Load the sample Excel file
        Workbook workbook = new Workbook();
        workbook.loadFromFile("Sample.xlsx");
        //Get the first worksheet
        Worksheet sheet = workbook.getWorksheets().get(0);

        //set the font
        ExcelFont font = workbook.createFont();
        font.setFontName("Arial");
        font.setSize(11);
        font.setKnownColor(ExcelColors.Orange);

        CellRange range = sheet.getCellRange("D1");
        //Add the commet
        ExcelComment comment = range.addComment();
        //Load the image
        BufferedImage bufferedImage = ImageIO.read(new File("Logo.jpg"));
        //Use the image to fill the comment
        comment.getFill().customPicture(bufferedImage, "Logo.jpg");

        //Set the height and width for the comment
        comment.setHeight(bufferedImage.getHeight());
        comment.setWidth(bufferedImage.getWidth());
        //Show the comment
        comment.setVisible(true);

        //Save the document to file
        workbook.saveToFile("output/setimageComment.xlsx", ExcelVersion.Version2013);

    }
}

Output:

Add image comment to Excel in Java

This article shows you how to download a PDF document from an URL using Spire.PDF with C# and VB.NET.

C#
using System.IO;
using System.Net;
using Spire.Pdf;

namespace DownloadPdfFromUrl
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a PdfDocument object
            PdfDocument doc = new PdfDocument();

            //Create a WebClient object
            WebClient webClient = new WebClient();

            //Download data from URL and save as memory stream
            using (MemoryStream ms = new MemoryStream(webClient.DownloadData("https://www.e-iceblue.com/article/toDownload.pdf")))
            {
                //Load the stream
                doc.LoadFromStream(ms);
            }

            //Save to PDF file
            doc.SaveToFile("result.pdf", FileFormat.PDF);
        }
    }
}
VB.NET
Imports System.IO
Imports System.Net
Imports Spire.Pdf

Namespace DownloadPdfFromUrl
    Class Program
        Shared  Sub Main(ByVal args() As String)
            'Create a PdfDocument object
            Dim doc As PdfDocument = New PdfDocument()
 
            'Create a WebClient object
            Dim webClient As WebClient = New WebClient()
 
            'Download data from URL and save as memory stream
            Imports(MemoryStream ms = New MemoryStream(webClient.DownloadData("https:'www.e-iceblue.com/article/toDownload.pdf")))
            {
                'Load the stream
                doc.LoadFromStream(ms)
            }
 
            'Save to PDF file
            doc.SaveToFile("result.pdf", FileFormat.PDF)
        End Sub
    End Class
End Namespace

Download PDF Document from URL in C#, VB.NET

page 114

Coupon Code Copied!

Christmas Sale

Celebrate the season with exclusive savings

Save 10% Sitewide

Use Code:

View Campaign Details