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 filePdfDocument doc = new PdfDocument();doc.LoadFromFile(@"C:\Users\Administrator\Desktop\Example.pdf");//load the certificate .pfx filePdfCertificate cert = new PdfCertificate(@"C:\Users\Administrator\Desktop\gary.pfx", "e-iceblue");//add a signature to the specified positionPdfSignature signature = new PdfSignature(doc, doc.Pages[0], cert, "signature");signature.Bounds = new RectangleF(new PointF(350, 700), new SizeF(180, 90));//set the signature contentsignature.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 serverstring url = "http://timestamp.wosign.com/rfc3161";signature.ConfigureTimestamp(url);//save to filedoc.SaveToFile("output.pdf");}}}

[VB.NET]

Imports Spire.PdfImports Spire.Pdf.GraphicsImports Spire.Pdf.SecurityImports System.DrawingNamespace SignPDFwithTimestampClass ProgramPrivate Shared Sub Main(args As String())'create a PdfDocument object and load a PDF fileDim doc As PdfDocument = New PdfDocument()doc.LoadFromFile("C:\Users\Administrator\Desktop\Example.pdf")'load the certificate .pfx fileDim cert As PdfCertificate = New PdfCertificate("C:\Users\Administrator\Desktop\gary.pfx","e-iceblue")'add a signature to the specified positionDim 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 contentsignature.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.ForbidChangessignature.GraphicsMode = GraphicMode.SignImageAndSignDetailsignature.SignImageSource = PdfImage.FromFile("C:\Users\Administrator\Desktop\company-logo.jpg")'configure a timestamp serverDim url As String = "http://timestamp.wosign.com/rfc3161"signature.ConfigureTimestamp(url)'save to filedoc.SaveToFile("output.pdf")End SubEnd ClassEnd Namespace

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