Sign document with analysis of the Sign process result

com.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 com.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()
{
    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)
        System.out.print("Sign-process was executed for "+signResult.getProcessingTime()+" mls");
        System.out.print("Input document size "+signResult.getSourceDocumentSize()+" bytes");
        System.out.print("Output document size "+signResult.getDestinDocumentSize()+" bytes");
        System.out.print("Total processed signatures "+signResult.getTotalSignatures());
        if (signResult.getFailed().size() == 0)
        {
            System.out.print("\nAll signatures were successfully created!");
        }
        else
        {
            System.out.print("Successfully created signatures : "+signResult.getSucceeded().size());
            System.out.print("Failed signatures : "+signResult.getFailed().size());
        }
        System.out.print("\nList of newly created signatures:");
        int number = 1;
        for (BaseSignature temp : signResult.getSucceeded())
        {
            System.out.print("Signature #"+ +number++ +": Type: "+temp.getSignatureType()+" Id:"+temp.getSignatureId()+", Location: "+temp.getLeft()+"x"+temp.getTop()+". Size: "+temp.getWidth()+"x"+temp.getHeight());
        }
    }
}

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.