GemBox.Pdf
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    PdfSignature Class

    Namespace:
    GemBox.Pdf.Forms
    Assembly:
    GemBox.Pdf.dll

    A digital signature (PDF 1.3) may be used to authenticate the identity of a user and the document's contents. It stores information about the signer and the state of the document when it was signed.

    • C#
    • VB.NET
    public sealed class PdfSignature : PdfObject
    Public NotInheritable Class PdfSignature
        Inherits PdfObject
    Inheritance:
    System.Object
    PdfObject
    PdfSignature

    Properties

    ContactInfo

    (Optional) Information provided by the signer to enable a recipient to contact the signer to verify the signature.

    Example: A phone number.

    • C#
    • VB.NET
    public string ContactInfo { get; set; }
    Public Property ContactInfo As String
    Property Value
    System.String

    Information provided by the signer to enable a recipient to contact the signer to verify the signature.

    See Also
    PDF Specification ISO 32000-1:2008, section '12.8 Digital Signatures'

    Content

    Gets the content of the PdfSignature.

    For public-key signatures, Content should be either a DER-encoded PKCS#1 binary data object (octet string) or a DER-encoded CMS binary data object.

    For document timestamp signatures, Content shall be the TimeStampToken as specified in RFC 3161 as updated by RFC 5816. The value of the messageImprint field within the TimeStampToken shall be a hash of the bytes of the document indicated by the ByteRange and the ByteRange shall specify the complete PDF file contents (excepting the Content value).

    • C#
    • VB.NET
    public PdfSignatureContent Content { get; }
    Public ReadOnly Property Content As PdfSignatureContent
    Property Value
    PdfSignatureContent

    The content of the PdfSignature.

    See Also
    PDF Specification ISO 32000-1:2008, section '12.8 Digital Signatures'

    ContentsLength

    Gets or sets the length of the Content (in bytes).

    • C#
    • VB.NET
    public int ContentsLength { get; set; }
    Public Property ContentsLength As Integer
    Property Value
    System.Int32

    The length of the Content (in bytes).

    Date

    (Optional) The time of signing. Depending on the signature handler, this may be a normal unverified computer time or a time generated in a verifiable way from a secure time server.

    This value should be used only when the time of signing is not available in the signature.

    Example: A time stamp can be embedded in a PKCS#7 binary data object (see 12.8.3.3, "PKCS#7 Signatures as used in ISO 32000").

    • C#
    • VB.NET
    public DateTimeOffset? Date { get; set; }
    Public Property Date As DateTimeOffset?
    Property Value
    System.Nullable<System.DateTimeOffset>

    The time of signing.

    See Also
    PDF Specification ISO 32000-1:2008, section '12.8 Digital Signatures'

    FileSectionDepth

    Gets the depth of the PDF file section that contains the PdfSignature or -1 if the PdfSignature is not contained in any PDF file section.

    • C#
    • VB.NET
    public int FileSectionDepth { get; }
    Public ReadOnly Property FileSectionDepth As Integer
    Property Value
    System.Int32

    The depth of the PDF file section that contains the PdfSignature or -1 if the PdfSignature is not contained in any PDF file section.

    Remarks

    The depth of the last PDF file section is 0 because a PDF file should be read from its end. The depth of all previous PDF file sections is greater than 0. Previous PDF file sections exist if the PDF file was incrementally updated.

    If the PDF file contains multiple PdfSignatures, the PdfSignature that is last applied should have FileSectionDepth equal to 0 and FileSectionDepth of all previously applied PdfSignatures should increase incrementally by 1. Otherwise, there might be one or more PDF file sections containing modifications that invalidate last applied and/or previously applied PdfSignatures.

    In PDF viewer/editor applications, a PDF file section that contains a PdfSignature is usually called a Signed Version or Revision of a PDF file and the last PDF file section is usually called the Current Version of a PDF file. For more information, see View previous versions of a digitally signed document and Compare versions of a signed document.

    note

    A PDF file section that contains a PdfSignature could also contain other modifications that might invalidate previously applied PdfSignatures (for example, changing the content of a page) and a PDF file section that doesn't contain a PdfSignature could have modifications that do not invalidate previously applied PdfSignatures (see Digital Signature Workflows examples). This depends on the transform methods applied to the PdfSignature (exposed via the Locks property) that guide the modification detection analysis that takes place when the signature is validated. The modification detection analysis is a complex process (for more information, see StackOverflow answers How to Validate Changes and Allowed actions for certified documents and for signed but uncertified documents and Adobe technical white paper Adobe Acrobat 9 Digital Signatures, Changes and Improvements, especially its section "Allowed and disallowed changes") and is currently not supported by GemBox.Pdf when validating the signature via Validate() method.

    Format

    (Optional) A name that describes the encoding of the signature value and key information in the signature dictionary. A PDF processor may use any handler that supports this format to validate the signature.

    • C#
    • VB.NET
    public PdfSignatureFormat Format { get; }
    Public ReadOnly Property Format As PdfSignatureFormat
    Property Value
    PdfSignatureFormat

    A name that describes the encoding of the signature value and key information in the signature dictionary.

    See Also
    PDF Specification ISO 32000-1:2008, section '12.8 Digital Signatures'

    Location

    (Optional) The CPU host name or physical location of the signing.

    • C#
    • VB.NET
    public string Location { get; set; }
    Public Property Location As String
    Property Value
    System.String

    The CPU host name or physical location of the signing.

    See Also
    PDF Specification ISO 32000-1:2008, section '12.8 Digital Signatures'

    Locks

    Gets the set of PdfSignatureLocks that specify what changes, made to the document after the signature was applied, invalidate the signature.

    If the value is null, then the signature does not specify a Reference entry.

    To set the Locks, sign the PdfSignatureField with a PdfSigner whose AuthorPermission is not null or use any SetLockedFields() method before signing on a PdfSignatureField that holds the signature.

    • C#
    • VB.NET
    public IList<PdfSignatureLock> Locks { get; }
    Public ReadOnly Property Locks As IList(Of PdfSignatureLock)
    Property Value
    System.Collections.Generic.IList<PdfSignatureLock>

    The set of PdfSignatureLocks that specify what changes, made to the document after the signature was applied, invalidate the signature.

    See Also
    PDF Specification ISO 32000-1:2008, section '12.8 Digital Signatures'

    Name

    (Optional) The name of the person or authority signing the document.

    This value should be used only when it is not possible to extract the name from the signature.

    Example: From the certificate of the signer.

    • C#
    • VB.NET
    public string Name { get; set; }
    Public Property Name As String
    Property Value
    System.String

    The name of the person or authority signing the document.

    See Also
    PDF Specification ISO 32000-1:2008, section '12.8 Digital Signatures'

    Reason

    (Optional) The reason for the signing, such as ( I agree … ).

    • C#
    • VB.NET
    public string Reason { get; set; }
    Public Property Reason As String
    Property Value
    System.String

    The reason for the signing, such as ( I agree … ).

    See Also
    PDF Specification ISO 32000-1:2008, section '12.8 Digital Signatures'

    Methods

    ComputeHash(PdfHashAlgorithm)

    Computes the hash of the bytes of the document indicated by the ByteRange (the ByteRange should specify the complete PDF file contents, except the Content value) with the specified algorithm.

    • C#
    • VB.NET
    public byte[] ComputeHash(PdfHashAlgorithm hashAlgorithm)
    Public Function ComputeHash(hashAlgorithm As PdfHashAlgorithm) As Byte()
    Parameters
    hashAlgorithm
    PdfHashAlgorithm

    The algorithm with which to compute the hash.

    Returns
    System.Byte[]

    The computed hash of the bytes of the document indicated by the ByteRange.

    Validate()

    Validates the PdfSignature.

    caution

    This method validates only that the document has not been modified since the PdfSignature was applied. The signer's identity (its certificate validity and revocation status) is currently not validated.

    • C#
    • VB.NET
    public PdfSignatureValidationResult Validate()
    Public Function Validate As PdfSignatureValidationResult
    Returns
    PdfSignatureValidationResult

    An instance of a PdfSignatureValidationResult that contains a detailed error information for the status of the signature validation.

    Inherited Properties

    Metadata

    (Optional; PDF 1.4) A metadata stream containing metadata for the component.

    (Inherited from PdfObject)

    Extension Methods

    PdfObjectExtensions.GetDictionary(PdfObject)
    PdfObjectExtensions.GetOrAddDictionary(PdfObject)
    PdfObjectExtensions.GetArray(PdfObject)

    Examples

    Digital signature examples
    Digital signature validation example

    See Also

    PDF Specification ISO 32000-1:2008, section '12.8 Digital Signatures'
    Digital Signatures in a PDF
    Adobe Acrobat 9 Digital Signatures, Changes and Improvements
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.