Sign document with different Text signature implementation

GroupDocs.Signature provides TextSignOptions class with property SignatureImplementation of enumeration type TextSignatureImplementation to specify various implementations of Text Signatures with following values and its meaning

Here are the steps to add Text signature into document with various text signature implementation types with GroupDocs.Signature:

Sign document with Text signature and Stamp implementation type

This example shows how to add Text signature with Stamp signature implementation to document.

using (Signature signature = new Signature("sample.pdf"))
{
    TextSignOptions options = new TextSignOptions("John Smith")
    {
        // set alternative signature implementation on document page
        SignatureImplementation = TextSignatureImplementation.Stamp,
        // set alignment
        VerticalAlignment = VerticalAlignment.Top,
        HorizontalAlignment = HorizontalAlignment.Right,
        // set margin with 20 pixels for all sides
        Margin = new Padding(20)
    };
    // sign document to file
    SignResult signResult = signature.Sign("signed.pdf", options);
    // analyzing result
    Console.WriteLine("List of newly created signatures:");
    int number = 1;
    foreach (BaseSignature temp in signResult.Succeeded)
    {
        Console.WriteLine($"Signature #{number++}: Type: {temp.SignatureType} Id:{temp.SignatureId},
            Location: {temp.Left}x{temp.Top}. Size: {temp.Width}x{temp.Height}");
    }
}

Sign document with Text signature and Annotation implementation type

This example shows how to add Text signature with Annotation signature implementation to document.

using (Signature signature = new Signature("sample.pdf"))
{
    TextSignOptions options = new TextSignOptions("John Smith")
    {
        // set alternative signature implementation on document page
        SignatureImplementation = TextSignatureImplementation.Annotation,
        // for Pdf document type ther's ability to setup exteneded appearences
        Appearance = new PdfTextAnnotationAppearance()
        {
            Border = new Border()
            {
                Color = Color.Blue,
                DashStyle = DashStyle.Dash,
                Weight = 2,
            },
            BorderEffect = PdfTextAnnotationBorderEffect.Cloudy,
            BorderEffectIntensity = 2,
            HCornerRadius = 10,
            // text content of an annotation
            Contents = "Sample",
            Subject = "Sample subject",
            Title = "Sample Title",
        },
        // set alignment
        VerticalAlignment = VerticalAlignment.Top,
        HorizontalAlignment = HorizontalAlignment.Right,
        // set margin with 20 pixels for all sides
        Margin = new Padding(20)
    };
    // sign document to file
    SignResult signResult = signature.Sign("signed.pdf", options);
    // analyzing result
    Console.WriteLine("List of newly created signatures:");
    int number = 1;
    foreach (BaseSignature temp in signResult.Succeeded)
    {
        Console.WriteLine($"Signature #{number++}: Type: {temp.SignatureType} Id:{temp.SignatureId},
            Location: {temp.Left}x{temp.Top}. Size: {temp.Width}x{temp.Height}");
    }
}

Sign document with Text signature and Image implementation type

This example shows how to add Text signature with Image signature implementation to document.

using (Signature signature = new Signature("sample.pdf"))
{
    TextSignOptions options = new TextSignOptions("John Smith")
    {
        // set alternative signature implementation on document page
        SignatureImplementation = TextSignatureImplementation.Image,
        // set alignment
        VerticalAlignment = VerticalAlignment.Top,
        HorizontalAlignment = HorizontalAlignment.Right,
        // set margin with 20 pixels for all sides
        Margin = new Padding(20)
    };
    // sign document to file
    SignResult signResult = signature.Sign("signed.pdf", options);
    // analyzing result
    Console.WriteLine("List of newly created signatures:");
    int number = 1;
    foreach (BaseSignature temp in signResult.Succeeded)
    {
        Console.WriteLine($"Signature #{number++}: Type: {temp.SignatureType} Id:{temp.SignatureId},
            Location: {temp.Left}x{temp.Top}. Size: {temp.Width}x{temp.Height}");
    }
}

Sign document with Text signature and Sticker implementation type

This example shows how to add Text signature with Sticker signature implementation to document.

using (Signature signature = new Signature("sample.pdf"))
{
    TextSignOptions options = new TextSignOptions("John Smith")
    {
        // set alternative signature implementation on document page
        SignatureImplementation = TextSignatureImplementation.Sticker,

        // set alignment
        VerticalAlignment = VerticalAlignment.Top,
        HorizontalAlignment = HorizontalAlignment.Right,
        // set margin with 20 pixels for all sides
        Margin = new Padding(20)
    };
    // sign document to file
    SignResult signResult = signature.Sign("signed.pdf", options);
    // analyzing result
    Console.WriteLine("List of newly created signatures:");
    int number = 1;
    foreach (BaseSignature temp in signResult.Succeeded)
    {
        Console.WriteLine($"Signature #{number++}: Type: {temp.SignatureType} Id:{temp.SignatureId},
            Location: {temp.Left}x{temp.Top}. Size: {temp.Width}x{temp.Height}");
    }
}

Sign document with Text signature and Form Field implementation type

This example shows how to add Text signature with FormField signature implementation to document.

using (Signature signature = new Signature("sample.docx"))
{
    TextSignOptions ffOptions1 = new TextSignOptions("John Smith")
    {
        // set alternative signature implementation on document page
        SignatureImplementation = TextSignatureImplementation.FormField,
        FormTextFieldType = FormTextFieldType.PlainText,
        FormTextFieldTitle = "UserSignatureFullName"
    };
    TextSignOptions ffOptions2 = new TextSignOptions("Document is approved")
    {
        // set alternative signature implementation on document page
        SignatureImplementation = TextSignatureImplementation.FormField,
        FormTextFieldType = FormTextFieldType.RichText,
        FormTextFieldTitle = "UserSignatureComment"
    };
    List<SignOptions> listOptions = new List<SignOptions>();
    listOptions.Add(ffOptions1);
    listOptions.Add(ffOptions2);
    // sign document to file
    SignResult signResult = signature.Sign("signed.docx", listOptions);
    // analyzing result
    Console.WriteLine("List of newly created signatures:");
    int number = 1;
    foreach (BaseSignature temp in signResult.Succeeded)
    {
        Console.WriteLine($"Signature #{number++}: Type: {temp.SignatureType} Id:{temp.SignatureId},
            Location: {temp.Left}x{temp.Top}. Size: {temp.Width}x{temp.Height}");
    }
}

More resources

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online Apps

Along with the full-featured .NET library, we provide simple but powerful free online apps.

To sign PDF, Word, Excel, PowerPoint, and other documents you can use the online apps from the GroupDocs.Signature App Product Family.