VintaSoft Imaging .NET SDK 15.2: Документация для .NET разработчика
Vintasoft.Imaging.Pdf.Tree Namespace / PdfPage Class / AddVisibleDigitalSignatureWithTextAppearance Methods / AddVisibleDigitalSignatureWithTextAppearance(X509Certificate2,String,String,String,RectangleF) Method
Синтаксис Example Требования Смотрите также
В этом разделе
AddVisibleDigitalSignatureWithTextAppearance(X509Certificate2,String,String,String,RectangleF) Метод (PdfPage)
В этом разделе
Добавляет видимую цифровую подпись с настраиваемым внешним видом на эту PDF страницу.
Синтаксис
'Declaration

Public Overloads Sub AddVisibleDigitalSignatureWithTextAppearance( _
ByVal certificate
Сертификат X509.
As System.Security.Cryptography.X509Certificates.X509Certificate2, _
ByVal signatureName
Имя подписи.
As System.String, _
ByVal signatureReason
Причина подписи.
As System.String, _
ByVal signatureText
Текст подписи.
As System.String, _
ByVal signatureRect
Прямоугольник подписи.
As System.Drawing.RectangleF _
)
public void AddVisibleDigitalSignatureWithTextAppearance(
System.Security.Cryptography.X509Certificates.X509Certificate2 certificate,
System.String signatureName,
System.String signatureReason,
System.String signatureText,
System.Drawing.RectangleF signatureRect
)

Parameters

certificate
Сертификат X509.
signatureName
Имя подписи.
signatureReason
Причина подписи.
signatureText
Текст подписи.
signatureRect
Прямоугольник подписи.
Пример

Вот пример, который показывает, как подписать PDF документ с помощью видимой подписи в текстовом виде:


Imports System.Drawing
Imports System.Security.Cryptography.X509Certificates
Imports Vintasoft.Imaging.Pdf
Imports Vintasoft.Imaging.Pdf.Tree

''' <summary>
''' Adds visible digital signature with text appearance to a PDF page.
''' </summary>
Public Class AddVisibleDigitalSignatureWithTextAppearanceExample
    Public Shared Sub Run()
        ' get the X509 certificate from .pfx-file
        Using certificate As New X509Certificate2("TestCertificate.pfx", "test")
            ' get the signer name from X509 certificate
            Dim signerName As String = certificate.GetNameInfo(X509NameType.SimpleName, False)

            ' open PDF document
            Using pdfDocument As New PdfDocument("TestDocumentToSign.pdf")
                ' get the first PDF page
                Dim pdfPage As PdfPage = pdfDocument.Pages(0)

                ' add visible digital signature with text appearance to the PDF page
                pdfPage.AddVisibleDigitalSignatureWithTextAppearance(certificate, "Signature", _
                    "Approve document", String.Format("Digitally signed by" & vbLf & "{0}", signerName), _
                    New RectangleF(20, 20, 250, 100), False)

                ' sign PDF document and save PDF document to the output file
                pdfDocument.SaveChanges("TestDocumentToSign-signed-text.pdf")
            End Using
        End Using
    End Sub
End Class


using System.Drawing;
using System.Security.Cryptography.X509Certificates;
using Vintasoft.Imaging.Pdf;
using Vintasoft.Imaging.Pdf.Tree;

/// <summary>
/// Adds visible digital signature with text appearance to a PDF page.
/// </summary>
public class AddVisibleDigitalSignatureWithTextAppearanceExample
{
    public static void Run()
    {
        // get the X509 certificate from .pfx-file
        using (X509Certificate2 certificate = new X509Certificate2("TestCertificate.pfx", "test"))
        {
            // get the signer name from X509 certificate
            string signerName = certificate.GetNameInfo(X509NameType.SimpleName, false);

            // open PDF document
            using (PdfDocument pdfDocument = new PdfDocument("TestDocumentToSign.pdf"))
            {
                // get the first PDF page
                PdfPage pdfPage = pdfDocument.Pages[0];

                // add visible digital signature with text appearance to the PDF page
                pdfPage.AddVisibleDigitalSignatureWithTextAppearance(
                    certificate, "Signature", "Approve document", string.Format("Digitally signed by\n{0}", signerName),
                    new RectangleF(20, 20, 250, 100), false);

                // sign PDF document and save PDF document to the output file
                pdfDocument.SaveChanges("TestDocumentToSign-signed-text.pdf");
            }
        }
    }
}

Требования

Целевые платформы: .NET 11; .NET 10; .NET 9; .NET 8; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

Смотрите также