Click or drag to resize

PdfDigitalSignatureDetails Class

Represents a class that stores details for signing a document with a digital signature.
Inheritance Hierarchy
SystemObject
  SautinSoft.DocumentPdfDigitalSignatureDetails

Namespace:  SautinSoft.Document
Assembly:  SautinSoft.Document (in SautinSoft.Document.dll) Version: 4.0.11.12 (4.0.11.12)
Syntax
public sealed class PdfDigitalSignatureDetails

The PdfDigitalSignatureDetails type exposes the following members.

Properties
  NameDescription
Public propertyCertificateBytes
Gets or sets the byte array that contains data from an X.509 certificate.
Public propertyCode exampleCertificatePassword
Gets or sets the password required to access the X.509 certificate data.
Public propertyCode exampleCertificatePath
Gets or sets the file path to the X.509 certificate.
Public propertyCode exampleContactInfo
Gets or sets the contact information provided by the signer to enable a recipient to contact the signer to verify the signature.
Public propertyCode exampleLocation
Gets or sets the CPU host name or physical location of the signing.
Public propertyCode exampleReason
Gets or sets the reason for the signing.
Public propertyCode exampleSignature
Gets or sets the signature.
Public propertyCode exampleSignatureLine
Gets or sets the signature line (anchor).
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Examples
Generate PDF document with the digital signature using C#
using System.IO;
using System.Linq;
using SautinSoft.Document;
using SautinSoft.Document.Drawing;
namespace Sample
{
    class Sample
    {

        static void Main(string[] args)
        {
            DigitalSignature();
        }

        /// <summary>
        /// Load an existing document (*.docx, *.rtf, *.pdf, *.html, *.txt, *.pdf) and save it in a PDF document with the digital signature.
        /// </summary>
        /// <remarks>
        /// Details: https://sautinsoft.com/products/document/examples/digital-signature-net-csharp-vb.php
        /// </remarks>
        public static void DigitalSignature()
        {
            // Path to a loadable document.
            string loadPath = @"..\..\digitalsignature.docx";
            string savePath = "Result.pdf";

            DocumentCore dc = DocumentCore.Load(loadPath);

            // Create a new invisible Shape for the digital signature.       
            // Place the Shape into top-left corner (0 mm, 0 mm) of page.
            Shape signatureShape = new Shape(dc, Layout.Floating(new HorizontalPosition(0f, LengthUnit.Millimeter, HorizontalPositionAnchor.LeftMargin),
                                    new VerticalPosition(0f, LengthUnit.Millimeter, VerticalPositionAnchor.TopMargin), new Size(1, 1)));
            ((FloatingLayout)signatureShape.Layout).WrappingStyle = WrappingStyle.InFrontOfText;
            signatureShape.Outline.Fill.SetEmpty();

            // Find a first paragraph and insert our Shape inside it.
            Paragraph firstPar = dc.GetChildElements(true).OfType<Paragraph>().FirstOrDefault();
            firstPar.Inlines.Add(signatureShape);

            // Picture which symbolizes a handwritten signature.
            Picture signaturePict = new Picture(dc, @"..\..\signature.png");

            // Signature picture will be positioned:
            // 14.5 cm from Top of the Shape.
            // 4.5 cm from Left of the Shape.
            signaturePict.Layout = Layout.Floating(
               new HorizontalPosition(4.5, LengthUnit.Centimeter, HorizontalPositionAnchor.Page),
               new VerticalPosition(14.5, LengthUnit.Centimeter, VerticalPositionAnchor.Page),
               new Size(20, 10, LengthUnit.Millimeter));

            PdfSaveOptions options = new PdfSaveOptions();

            // Path to the certificate (*.pfx).
            options.DigitalSignature.CertificatePath = @"..\..\sautinsoft.pfx";

            // The password for the certificate.
            // Each certificate is protected by a password.
            // The reason is to prevent unauthorized the using of the certificate.
            options.DigitalSignature.CertificatePassword = "123456789";

            // Additional information about the certificate.
            options.DigitalSignature.Location = "World Wide Web";
            options.DigitalSignature.Reason = "Document.Net by SautinSoft";
            options.DigitalSignature.ContactInfo = "info@sautinsoft.com";

            // Placeholder where signature should be visualized.
            options.DigitalSignature.SignatureLine = signatureShape;

            // Visual representation of digital signature.
            options.DigitalSignature.Signature = signaturePict;

            dc.Save(savePath, options);

            // Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(savePath) { UseShellExecute = true });
        }
    }
}
Generate PDF document with the digital signature using VB.Net
Imports System
Imports System.Linq
Imports System.IO
Imports SautinSoft.Document
Imports SautinSoft.Document.Drawing

Module Sample
    Sub Main()
        DigitalSignature()
    End Sub

    ''' <summary>
    ''' Load an existing document (*.docx, *.rtf, *.pdf, *.html, *.txt, *.pdf) and save it in a PDF document with the digital signature.
    ''' </summary>
    ''' <remarks>
    ''' Details: https://sautinsoft.com/products/document/examples/digital-signature-net-csharp-vb.php
    ''' </remarks>
    Sub DigitalSignature()
        ' Path to a loadable document.
        Dim loadPath As String = "..\digitalsignature.docx"
        Dim savePath As String = "Result.pdf"

        Dim dc As DocumentCore = DocumentCore.Load(loadPath)

        ' Create a new invisible Shape for the digital signature.       
        ' Place the Shape into top-left corner (0 mm, 0 mm) of page.
        Dim signatureShape As New Shape(dc, Layout.Floating(New HorizontalPosition(0F, LengthUnit.Millimeter, HorizontalPositionAnchor.LeftMargin), New VerticalPosition(0F, LengthUnit.Millimeter, VerticalPositionAnchor.TopMargin), New Size(1, 1)))
        CType(signatureShape.Layout, FloatingLayout).WrappingStyle = WrappingStyle.InFrontOfText
        signatureShape.Outline.Fill.SetEmpty()

        ' Find a first paragraph and insert our Shape inside it.
        Dim firstPar As Paragraph = dc.GetChildElements(True).OfType(Of Paragraph)().FirstOrDefault()
        firstPar.Inlines.Add(signatureShape)

        ' Picture which symbolizes a handwritten signature.
        Dim signaturePict As New Picture(dc, "..\signature.png")

        ' Signature picture will be positioned:
        ' 14.5 cm from Top of the Shape.
        ' 4.5 cm from Left of the Shape.
        signaturePict.Layout = Layout.Floating(New HorizontalPosition(4.5, LengthUnit.Centimeter, HorizontalPositionAnchor.Page), New VerticalPosition(14.5, LengthUnit.Centimeter, VerticalPositionAnchor.Page), New Size(20, 10, LengthUnit.Millimeter))

        Dim options As New PdfSaveOptions()

        ' Path to the certificate (*.pfx).
        options.DigitalSignature.CertificatePath = "..\sautinsoft.pfx"

        ' The password for the certificate.
        ' Each certificate is protected by a password.
        ' The reason is to prevent unauthorized the using of the certificate.
        options.DigitalSignature.CertificatePassword = "123456789"

        ' Additional information about the certificate.
        options.DigitalSignature.Location = "World Wide Web"
        options.DigitalSignature.Reason = "Document.Net by SautinSoft"
        options.DigitalSignature.ContactInfo = "info@sautinsoft.com"

        ' Placeholder where signature should be visualized.
        options.DigitalSignature.SignatureLine = signatureShape

        ' Visual representation of digital signature.
        options.DigitalSignature.Signature = signaturePict

        dc.Save(savePath, options)

        ' Open the result for demonstration purposes.
        System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(savePath) With {.UseShellExecute = True})
    End Sub
End Module
See Also