Xceed Words for .NET v5.2 Documentation
Xceed.Words.NET Assembly / Xceed.Words.NET Namespace / DocX Class / Sign Method / Sign(String,String,DigitalCertificate,SignOptions) Method
The path of the document to sign.
The path to store the signed document.
The certificate used to sign the document.
The options set to sign the document. By default, null.
Example


In This Topic
    Sign(String,String,DigitalCertificate,SignOptions) Method
    In This Topic
    Signs an input document with a certificate and sign options, and saves the result in an output document.
    Syntax
    'Declaration
     
    
    Public Overloads Shared Sub Sign( _
       ByVal inputFileName As String, _
       ByVal outputFileName As String, _
       ByVal certificate As DigitalCertificate, _
       Optional ByVal signOptions As SignOptions _
    ) 
    'Usage
     
    
    Dim inputFileName As String
    Dim outputFileName As String
    Dim certificate As DigitalCertificate
    Dim signOptions As SignOptions
     
    DocX.Sign(inputFileName, outputFileName, certificate, signOptions)

    Parameters

    inputFileName
    The path of the document to sign.
    outputFileName
    The path to store the signed document.
    certificate
    The certificate used to sign the document.
    signOptions
    The options set to sign the document. By default, null.
    Example
    // Add the SignatureLine to the document.
    mySignatureLine = document.AddSignatureLine();
    
    // Insert the SignatureLine in a document's paragraph.
    myParagraph.AppendSignatureLine( mySignatureLine );
    
    // Create a digital certificate in order to sign the document, by using a pfx file and its password.
    var certificate = DigitalCertificate.Create( "CustomCertificate.pfx", "xceed" );
    
      // Create SignOptions for the SignatureLine.
      // Use the SignatureLineId to match the SignatureLine id and set the image used to sign the SignatureLine.
      var signOptions = new SignOptions()
      {
        SignatureLineId = mySignatureLine.Id,
        SignatureLineImage = "MarkStoneSignature.png",
        Comments = "This document is now signed by Mark Stone."
      };   
    
      // Sign the document with the certificate and the SignOptions, related to the SignatureLine.
      DocX.Sign( "DocumentToSign.docx", "SignedDocument.docx", certificate, signOptions );
    Supported Frameworks

    .NET: net5.0, net5.0-windows, net6.0, net6.0-macos, net6.0-windows, net7.0, net7.0-macos, net7.0-windows, net8.0, net8.0-browser, net8.0-macos, net8.0-windows, net9.0, net9.0-browser, net9.0-macos, net9.0-windows, net10.0, net10.0-browser, net10.0-macos, net10.0-windows.

    .NET Framework: net40, net403, net45, net451, net452, net46, net461, net462, net463, net47, net471, net472, net48, net481.

    See Also