3

一部のプラグインとプログラムはこれを行うことができます。.netとitextSharpを使用してこれを行う方法の例またはチュートリアルはありますか??

署名された pdf を取得し、すべてのページに画像をスタンプし、別の署名を追加する必要があります。ファイルを開くときに、ドキュメントの最初の署名が有効である必要があります。

前もって感謝します。

4

2 に答える 2

1
Public Function sign(keystore As String, level As Integer, src As String, name As String, dest As String, sig As String, pass As String)
    ' Try
    'Dim store As System.Security.Cryptography.X509Certificates.X509Store = New System.Security.Cryptography.X509Certificates.X509Store
    'store.Open(System.Security.Cryptography.X509Certificates.OpenFlags.ReadOnly)
    'Dim sel As System.Security.Cryptography.X509Certificates.X509Certificate2Collection

    ' If sig <> "" And pass <> "" Then
    Try
        Dim y As Int16 = 200
        ' For i As Integer = 0 To sel.Count - 1
        Dim pdfReader As PdfReader = New PdfReader(src)
        Dim signedPdf = New FileStream(dest, FileMode.Create)
        Try
            Dim cert As X509Certificate2 = New X509Certificate2(sig, pass)
            Dim cp As Org.BouncyCastle.X509.X509CertificateParser = New Org.BouncyCastle.X509.X509CertificateParser()
            Dim chain As Org.BouncyCastle.X509.X509Certificate() = New Org.BouncyCastle.X509.X509Certificate() {cp.ReadCertificate(cert.RawData)}




            Dim stamper As PdfStamper
            stamper = PdfStamper.CreateSignature(pdfReader, signedPdf, "0"c, Nothing, True)
            Dim signatureAppearance As PdfSignatureAppearance = stamper.SignatureAppearance
            'signatureAppearance.SignatureGraphic = Image.GetInstance(pathToSignatureImage)
            signatureAppearance.SetVisibleSignature(name)

            signatureAppearance.CertificationLevel = level
            Dim externalSignature As IExternalSignature = New X509Certificate2Signature(cert, "SHA-1")
            ' Dim digest As IExternalSignature = New BouncyCastleDigest
            ' signatureAppearance.s 
            'signatureAppearance.SetVisibleSignature(New Rectangle(50,50,50,
            signatureAppearance.SignatureRenderingMode = PdfSignatureAppearance.RenderingMode.NAME_AND_DESCRIPTION
            MakeSignature.SignDetached(signatureAppearance, externalSignature, chain, Nothing, Nothing, Nothing, 0, CryptoStandard.CADES)
            ' MakeSignature. 

            ' End If

            ' Catch ex As Exception
            'MsgBox(ex.Message)
            ' End Try
        Catch ex As Exception

            MsgBox("Signature File Password is not correct for the user Id :" & error_userid)
            'Exit Function
        End Try
    Catch ex As Exception

    End Try
    Return 0
End Function
于 2014-08-06T11:25:57.100 に答える