本文将介绍如何使用Spire.Presentation for .NET给PowerPoint文档添加数字签名或删除PowerPoint文档中的现有数字签名。
添加数字签名
C#
using Spire.Presentation;
using System;
using System.Security.Cryptography.X509Certificates;
namespace AddDigitalSignature
{
class Program
{
static void Main(string[] args)
{
//创建Presentation实例
Presentation ppt = new Presentation();
//加载PowerPoint文档
ppt.LoadFromFile("Input.pptx");
//添加数字签名
X509Certificate2 x509 = new X509Certificate2("gary.pfx", "e-iceblue");
ppt.AddDigitalSignature(x509, "e-iceblue", DateTime.Now);
//保存结果文档
ppt.SaveToFile("AddDigitalSignature.pptx", FileFormat.Pptx2013);
}
}
}
VB.NET
Imports Spire.Presentation
Imports System
Imports System.Security.Cryptography.X509Certificates
Namespace AddDigitalSignature
Class Program
Private Shared Sub Main(ByVal args As String())
Dim ppt As Presentation = New Presentation()
ppt.LoadFromFile("Input.pptx")
Dim x509 As X509Certificate2 = New X509Certificate2("gary.pfx", "e-iceblue")
ppt.AddDigitalSignature(x509, "e-iceblue", DateTime.Now)
ppt.SaveToFile("AddDigitalSignature.pptx", FileFormat.Pptx2013)
End Sub
End Class
End Namespace
结果文档:
删除数字签名
C#
using Spire.Presentation;
using System;
using System.Security.Cryptography.X509Certificates;
namespace RemoveDigitalSignature
{
class Program
{
static void Main(string[] args)
{
//创建Presentation实例
Presentation ppt = new Presentation();
//加载PowerPoint文档
ppt.LoadFromFile("AddDigitalSignature.pptx");
//判断文档中是否有数字签名
if (ppt.IsDigitallySigned == true)
{
//删除所有数字签名
ppt.RemoveAllDigitalSignatures();
}
//保存结果文档
ppt.SaveToFile("RemoveDigitalSignature.pptx", FileFormat.Pptx2013);
}
}
}
VB.NET
Imports Spire.Presentation
Imports System
Imports System.Security.Cryptography.X509Certificates
Namespace RemoveDigitalSignature
Class Program
Private Shared Sub Main(ByVal args As String())
Dim ppt As Presentation = New Presentation()
ppt.LoadFromFile("AddDigitalSignature.pptx")
If ppt.IsDigitallySigned = True Then
ppt.RemoveAllDigitalSignatures()
End If
ppt.SaveToFile("RemoveDigitalSignature.pptx", FileFormat.Pptx2013)
End Sub
End Class
End Namespace
结果文档: