SignPAdESBB.vb
C# VB
'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''Imports SystemImports System.IOImports System.Collections.GenericImports System.Security.CryptographyImports System.Security.Cryptography.X509CertificatesImports GrapeCity.Documents.Pdf
'' This sample shows how to sign an existing PDF file containing'' an empty signature field with a signature that complies with'' PAdES (PDF Advanced Electronic Signatures) B-B level standard.Public Class SignPAdESBB Function CreatePDF(ByVal stream As Stream) As Integer Dim doc = New GcPdfDocument() Using s = File.OpenRead(Path.Combine("Resources", "PDFs", "SignPAdESBB.pdf")) doc.Load(s)
Dim pfxPath = Path.Combine("Resources", "Misc", "DsPdfTest.pfx") Dim cert = New X509Certificate2(pfxPath, "qq") Dim sp = SignatureProperties.CreatePAdES_B_B(cert) sp.SignatureAppearance.Caption = "PAdES B-B" sp.SignatureField = doc.AcroForm.Fields(0) doc.Sign(sp, stream) End Using
'' Done. Return doc.Pages.Count End FunctionEnd Class