Subscribing for signing process events

Signature class contains several events that are being called for different process stages

  • SignStarted to handle process start event. This event is occur once Sign method is called
  • SignProgress to handle progress event. This event occurs each time on signing each signature was completed.
  • SignCompleted to handle completion event. This event occurs once Sign process was completed.

Here are the steps to subscribe for signing process with GroupDocs.Signature:

  • Define required handler delegates to process signing events.
  • Create new instance of Signature class and pass source document path or stream as a constructor parameter.
  • Subscribe for required events
  • Instantiate required SignOptions object
  • Call Sign method of Signature class instance and pass signature options in it

Implement method for SignStarted event

GroupDocs.Signature expects ProcessStartEventHandler delegate to subscribe for SignStarted event

private static void OnSignStarted(Signature signature, ProcessStartEventArgs args)
{
    Console.WriteLine("Sign process started at {0} with {1} total signatures to be put in document", args.Started, args.TotalSignatures);
}

Implement method for SignProgress event

 private static void OnSignProgress(Signature signature, ProcessProgressEventArgs args)
 {
     Console.WriteLine("Sign progress. Processed {0} signatures. Time spent {1} mlsec", args.ProcessedSignatures, args.Ticks);
 }

Implement method for SignCompleted event

private static void OnSignCompleted(Signature signature, ProcessCompleteEventArgs args)
{
    Console.WriteLine("Sign process completed at {0} with {1} total signatures. Process took {2} mlsec", args.Completed, args.TotalSignatures, args.Ticks);
}

Subscribing for signing process events

private static void OnSignStarted(Signature signature, ProcessStartEventArgs args)
{
    Console.WriteLine("Sign process started at {0} with {1} total signatures to be put in document", args.Started, args.TotalSignatures);
}

private static void OnSignProgress(Signature signature, ProcessProgressEventArgs args)
{
    Console.WriteLine("Sign progress. Processed {0} signatures. Time spent {1} mlsec", args.ProcessedSignatures, args.Ticks);
}

private static void OnSignCompleted(Signature signature, ProcessCompleteEventArgs args)
{
    Console.WriteLine("Sign process completed at {0} with {1} total signatures. Process took {2} mlsec", args.Completed, args.TotalSignatures, args.Ticks);
}

public static void Run()
{
    using (Signature signature = new Signature("sample.pdf"))
    {
        signature.SignStarted += OnSignStarted;
        signature.SignProgress += OnSignProgress;
        signature.SignCompleted += OnSignCompleted;
        TextSignOptions options = new TextSignOptions("John Smith")
        {
            // set signature position
            Left = 100,
            Top = 100
        };

        // sign document to file
        signature.Sign("SignedSample", options);
    }
}

More resources

GitHub Examples

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

Free Online App

Along with full-featured .NET library we provide simple, but powerful free Apps.

You are welcome to eSign PDF, Word, Excel, PowerPoint documents with free to use online GroupDocs Signature App.