Sign document with analysis of the Sign process result

GroupDocs.SignatureΒ provides the each method result as the implementation of the IResult interface which contains the process metrics.

Here are the steps to analyze the process result with GroupDocs.Signature:

  • Create a new instance ofΒ SignatureΒ class and pass the source document path as a constructor parameter.
  • Instantiate theΒ SignOptionsΒ object with the required options and set the ZOrder property.
  • CallΒ SignΒ method ofΒ Β Signature class instance and passΒ SignOptionsΒ to it.
  • Analyze SignResultΒ response of the SignΒ method.

Sign document with result analysis

This example shows how to analize sign process result.

public static void Run()
{
    using (Signature signature = new Signature("sample.pdf"))
    {
        // create QRCode option with predefined QRCode text
        QrCodeSignOptions options = new QrCodeSignOptions("JohnSmith");

        // sign document to file
        SignResult signResult = signature.Sign("output.pdf", options);

        // analyze SignResult (IResult properties)
        Console.WriteLine($"Sign-process was executed for {signResult.ProcessingTime} mls");
        Console.WriteLine($"Input document size {signResult.SourceDocumentSize} bytes");
        Console.WriteLine($"Output document size {signResult.DestinDocumentSize} bytes");
        Console.WriteLine($"Total processed signatures {signResult.TotalSignatures}");
        if (signResult.Failed.Count == 0)
        {
            Console.WriteLine("\nAll signatures were successfully created!");
        }
        else
        {
            Console.WriteLine($"Successfully created signatures : {signResult.Succeeded.Count}");
            Helper.WriteError($"Failed signatures : {signResult.Failed.Count}");
        }
        Console.WriteLine("\nList of newly created signatures:");
        int number = 1;
        foreach (BaseSignature temp in signResult.Succeeded)
        {
            Console.WriteLine($"Signature #{number++}: Type: {temp.SignatureType} Id:{temp.SignatureId}");
        }
    }
}

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.