本文将介绍如何使用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
结果文档: