Sign document with Image signature - advanced

GroupDocs.Signatureย providesย ImageSignOptionsย classย to specify different options for Image signature as follow

Here are the steps to add Image signature into document with GroupDocs.Signature:

  • Create new instance ofย Signatureย class and pass source document path as a constructor parameter.
  • Instantiate theย ImageSignOptionsย object according to your requirements and specify image signature options.
  • Callย Signย method ofย Signatureย class instance and passย ImageSignOptionsย to it.
  • Analyzeย SignResultย result to check newly created signatures if needed.

This example shows how to specify different Image signature options. Seeย SignResult

using (Signature signature = new Signature("sample.xlsx"))
{
    ImageSignOptions options = new ImageSignOptions("sample.jpg")
    {
        // set signature position
        Left = 100,
        Top = 100,
        // set signature rectangle
        Width = 100,
        Height = 30,
        // set signature alignment
        // when VerticalAlignment is set the Top coordinate will be ignored.
        // Use Margin properties Top, Bottom to provide vertical offset
        VerticalAlignment = Domain.VerticalAlignment.Top,
        // when HorizontalAlignment is set the Left coordinate will be ignored.
        // Use Margin properties Left, Right to provide horizontal offset
        HorizontalAlignment = Domain.HorizontalAlignment.Right,
        Margin = new Padding() { Top = 20, Right = 20 },
        // set rotation
        RotationAngle = 45,
        // setup image additional appearance as Brightness and Border
        Appearance = new ImageAppearance()
        {
            Brightness = 0.9f,
            Border = new Border()
            {
                Color = Color.DarkGreen,
                DashStyle = DashStyle.DashLongDashDot,
                Transparency = 0.5,
                Visible = true,
                Weight = 2
            },
        }
    };

    // sign document to file
    SignResult signResult = signature.Sign("sgnedSample.xlsx", options);
    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 generate image signatures and/or sign your files with them for free, you can use the Generate Image online app.

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