Signature class supports cancellation for each of document processing (Sign, Verify, Search). The process cancellation happens over setting property getCancel of ProcessProgressEventArgs property in proper event handler.
for sign process this flag should be set to true in handler of SignProgress event. This event occurs each time on signing each signature was completed.
for verify process this flag should be set to true in handler of VerifyProgress event. This event occurs each time on verifying document page.
for search process this flag should be set to true in handler of SearchProgress event. This event occurs each time on searching document page per each options.
Cancel signing process
Here are the steps to provide cancellation for signing process with GroupDocs.Signature:
Define SignProgress event handler delegates to conditionally cancel the process.
Create new instance of Signature class and pass source document path or stream as a constructor parameter.
Subscribe for SignProgress event with proper handler method
Call sign method of Signature class instance and pass signature options in it
privatestaticvoidonSignProgress(Signaturesender,ProcessProgressEventArgsargs){// check if process takes more than 1 second (1000 milliseconds) processing cancellation
if(args.getTicks()>1000){args.setCancel(true);System.out.print("Sign progress was cancelled. Time spent "+args.getTicks()+" mlsec");}}publicstaticvoidrun(){try{Signaturesignature=newSignature("Sample.pdf");signature.SignProgress.add(newProcessProgressEventHandler(){publicvoidinvoke(Signaturesender,ProcessProgressEventArgsargs){onSignProgress(sender,args);}});TextSignOptionsoptions=newTextSignOptions("John Smith"){// ...
};// sign document to file
signature.sign("Signed.pdf",options);System.out.print("\nSource document signed successfully.\nFile saved at "+outputFilePath);}catch(Exceptione){thrownewGroupDocsSignatureException(e.getMessage());}}
Cancel verification process
Here are the steps to provide cancellation for verification process with GroupDocs.Signature:
Define VerifyProgress event handler delegates to conditionally cancel the process.
Create new instance of Signature class and pass source document path or stream as a constructor parameter.
Subscribe for VerifyProgress event with proper handler method
Call verify method of Signature class instance and pass verification options in it.
privatestaticvoidonVerifyProgress(Signaturesender,ProcessProgressEventArgsargs){// check if process takes more than 1 second (1000 milliseconds) processing cancellation
if(args.getTicks()>1000){args.setCancel(true);System.out.print("Verify progress was cancelled. Time spent "+args.getTicks()+" mlsec");}}publicstaticvoidrun(){try{Signaturesignature=newSignature("SampleSigned.pdf");signature.VerifyProgress.add(newProcessProgressEventHandler(){publicvoidinvoke(Signaturesender,ProcessProgressEventArgsargs){onVerifyProgress(sender,args);}});TextVerifyOptionsoptions=newTextVerifyOptions("John Smith"){// ...
};// sign document to file
VerificationResultresult=signature.verify(options);}catch(Exceptione){thrownewGroupDocsSignatureException(e.getMessage());}}
Cancel search process
Here are the steps to provide cancellation of searching process with GroupDocs.Signature:
Define SearchProgress event handler delegates to conditionally cancel the process.
Create new instance of Signature class and pass source document path or stream as a constructor parameter.
Subscribe for SearchProgress event with proper handler method
Call search method of Signature class instance and pass search options in it
privatestaticvoidonSearchProgress(Signaturesender,ProcessProgressEventArgsargs){// check if process takes more than 1 second (1000 milliseconds) processing cancellation
if(args.getTicks()>1000){args.setCancel(true);System.out.print("Search progress was cancelled. Time spent "+args.getTicks()+" mlsec");}}publicstaticvoidrun(){try{Signaturesignature=newSignature("SampleSigned.pdf");signature.SearchProgress.add(newProcessProgressEventHandler(){publicvoidinvoke(Signaturesender,ProcessProgressEventArgsargs){onSearchProgress(sender,args);}});QrCodeSearchOptionsoptions=newQrCodeSearchOptions(QrCodeTypes.QR){// ...
};// search for signatures in document
List<QrCodeSignature>signatures=signature.search(QrCodeSignature.class,options);System.out.print("\nSource document contains following signatures.");for(QrCodeSignatureqr_signature:signatures){System.out.print("QRCode signature found at page "+qr_signature.getPageNumber()+" with type "+qr_signature.getEncodeType()+" and text "+qr_signature.getText());}}catch(Exceptione){thrownewGroupDocsSignatureException(e.getMessage());}}
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples:
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.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.