使用時(shí)間戳服務(wù)器對(duì) PDF 進(jìn)行數(shù)字簽名
Spire.PDF for .NET 是一款專門對(duì) Word 文檔進(jìn)行操作的 .NET 類庫(kù)。致力于在于幫助開(kāi)發(fā)人員輕松快捷高效地創(chuàng)建、編輯、轉(zhuǎn)換和打印 Microsoft Word 文檔,而無(wú)需安裝 Microsoft Word。
行號(hào)用于在每行文本旁邊顯示 Word 自動(dòng)計(jì)算的行數(shù)。當(dāng)我們需要參考合同或法律文件等文檔中的特定行時(shí),它非常有用。word中的行號(hào)功能允許我們?cè)O(shè)置起始值、編號(hào)間隔、與文本的距離以及行號(hào)的編號(hào)方式。使用 Spire.Doc,我們可以實(shí)現(xiàn)上述所有功能。本文將介紹如何將 HTML 轉(zhuǎn)換為 PDF。
歡迎加入spire技術(shù)交流群:767755948
數(shù)字時(shí)間戳用時(shí)間和日期標(biāo)記 PDF 簽名,以證明其完整性。時(shí)間戳表明文檔內(nèi)容存在于某個(gè)時(shí)間點(diǎn),且未發(fā)生變化。本文將介紹如何使用 Spire.PDF 對(duì)帶有時(shí)間戳服務(wù)器的 PDF 文檔進(jìn)行數(shù)字簽名。
代碼片段:
[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
輸出: