PDF控件Spire.PDF for .NET【安全】演示:使用时间戳服务器对 PDF 进行数字签名

Spire.PDF for .NET 是一款独立 PDF 控件,用于 .NET 程序中创建、编辑和操作 PDF 文档。使用 Spire.PDF 类库,开发人员可以新建一个 PDF 文档或者对现有的 PDF 文档进行处理,且无需安装 Adobe Acrobat。

E-iceblue 功能类库Spire 系列文档处理组件均由中国本土团队研发,不依赖第三方软件,不受其他国家的技术或法律法规限制,同时适配国产操作系统如中科方德、中标麒麟等,兼容国产文档处理软件 WPS(如 .wps/.et/.dps 等格式

Spire.PDF for.net下载   Spire.PDF for java下载

数字时间戳用时间和日期标记 PDF 签名,作为完整性证明。时间戳表明文档的内容在某个时间点存在且未更改。本文将介绍如何使用 Spire.PDF 通过时间戳服务器对 PDF 文档进行数字签名。

代码片段

[C#]

using Spire.Pdf;
using Spire.Pdf.Graphics;
using Spire.Pdf.Security;
using System.Drawing;

namespace SignPDFwithTimestamp
{
class Program
{
static void Main(string[] args)
{
//create a PdfDocument object and load a PDF file
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(@"C:\Users\Administrator\Desktop\Example.pdf");

//load the certificate .pfx file
PdfCertificate cert = new PdfCertificate(@"C:\Users\Administrator\Desktop\gary.pfx", "e-iceblue");

//add a signature to the specified position
PdfSignature signature = new PdfSignature(doc, doc.Pages[0], cert, "signature");
signature.Bounds = new RectangleF(new PointF(350, 700), new SizeF(180, 90));

//set the signature content
signature.NameLabel = "Digitally signed by:Gary";
signature.LocationInfoLabel = "Location:";
signature.LocationInfo = "CN";
signature.ReasonLabel = "Reason: ";
signature.Reason = "Ensure authenticity";
signature.ContactInfoLabel = "Contact Number: ";
signature.ContactInfo = "028-81705109";
signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill | PdfCertificationFlags.ForbidChanges;
signature.GraphicsMode = GraphicMode.SignImageAndSignDetail;
signature.SignImageSource = PdfImage.FromFile(@"C:\Users\Administrator\Desktop\company-logo.jpg");

//configure a timestamp server
string url = "http://timestamp.wosign.com/rfc3161";
signature.ConfigureTimestamp(url);

//save to file
doc.SaveToFile("output.pdf");
}
}
}

[VB.NET]

Imports Spire.Pdf
Imports Spire.Pdf.Graphics
Imports Spire.Pdf.Security
Imports System.Drawing

Namespace SignPDFwithTimestamp
Class Program
Private Shared Sub Main(args As String())
'create a PdfDocument object and load a PDF file
Dim doc As PdfDocument = New PdfDocument()
doc.LoadFromFile("C:\Users\Administrator\Desktop\Example.pdf")

'load the certificate .pfx file
Dim cert As PdfCertificate = New PdfCertificate("C:\Users\Administrator\Desktop\gary.pfx","e-iceblue")

'add a signature to the specified position
Dim signature As PdfSignature = New PdfSignature(doc,doc.Pages(0),cert,"signature")
signature.Bounds = New RectangleF(New PointF(350, 700), New SizeF(180, 90))

'set the signature content
signature.NameLabel = "Digitally signed by:Gary"
signature.LocationInfoLabel = "Location:"
signature.LocationInfo = "CN"
signature.ReasonLabel = "Reason: "
signature.Reason = "Ensure authenticity"
signature.ContactInfoLabel = "Contact Number: "
signature.ContactInfo = "028-81705109"
signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill | PdfCertificationFlags.ForbidChanges
signature.GraphicsMode = GraphicMode.SignImageAndSignDetail
signature.SignImageSource = PdfImage.FromFile("C:\Users\Administrator\Desktop\company-logo.jpg")

'configure a timestamp server
Dim url As String = "http://timestamp.wosign.com/rfc3161"
signature.ConfigureTimestamp(url)

'save to file
doc.SaveToFile("output.pdf")
End Sub
End Class
End Namespace

如何使用 C#、VB.NET 中的时间戳服务器对 PDF 进行数字签名

以上便是如何用时间戳服务器对 PDF 进行数字签名,如果您有其他问题也可以继续浏览本系列文章,获取相关教程~

  • 27
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
免费Spire.PDF for .NET 是一款由e-iceblue公司开发的专业性的PDF文档创建组件。它能够使用户在不用Adobe Acrobat和其他外部控件的情况下,运用.NET 应用程序阅读,编写和操纵PDF 文档。Spire.PDF for .NET不仅可以运用在服端比如:ASP.NET 或者其他环境,还可以应用在Windows Forms 应用程序中。Spire.PDF for .NET 适合应用于所有常见的坏境中,比如:创建好的PDF文档可以存到磁盘中, 还可以在Windows Forms应用程序,ASP.NET 应用程序客户端浏览器中保存为数据流。 Spire.PDF for .NET 功能丰富。 除了基本的功能比如:绘制多种图形,图片,创建窗体字段,插入页眉页脚,输入数据表,自动对大型表格进行分页外,Spire.PDF for .NET还支持PDF数字签名,将HTML转换成PDF格式,提取PDF文档中的文本信息和图片,存为文本格式和各种图片格式,甚至可以将PDF中的附件提取出来。 主要功能 支持嵌入式字体,Truetype 字体和CJK字体。 支持绘图。比如:矩形,环形,弧形,椭圆形,也可以自定笔刷将其填充。 可以将图片从数据流,磁盘文件中载入到PDF 文档中。 在PDF 文档中既可以绘制梯状图形和矢量图像,还支持掩模和水印图像。 可以在PDF 文档中载入数据表。可以设置表中的行和列的格式,还可以在表内加入图形元素。 自动对PDF 中的大型表格进行分页。 创建窗体字段。比如在PDF 文档中创建按钮,文本框,列表框,复选框等等。 在PDF 中插入页眉页脚。 通过设置所有者密码和用户密码来加密PDF文档。 通过作者的签名来保护PDF文档。 读取当前PDF文档的表格并且填充表格。 HTML网页在转换到PDF文档时会拆分为多个大型页面,这些页面可以原原本本的展现在PDF文档中,而且在PDF文档的分页处没有任何文字的截断。用户还可以将这些网页在不需要临时文件的情况下,直接转换为数据流来创建PDF文档。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值