Following example demonstrates how to handle incorrect password exception.
// initialize LoadOptions with incorrect PasswordLoadOptionsloadOptions=newLoadOptions(){Password="1"};using(Signaturesignature=newSignature("ProtectedPwd.pdf",loadOptions)){try{QrCodeSignOptionsoptions=newQrCodeSignOptions("JohnSmith"){EncodeType=QrCodeTypes.QR,Left=100,Top=100};// try to sign document to file, we expect for PasswordRequiredExceptionsignature.Sign(outputFilePath,options);Console.WriteLine("\nSource document signed successfully.\nFile saved at "+outputFilePath);}catch(IncorrectPasswordExceptionex){Console.WriteLine($"HandlingIncorrectPasswordException: {ex.Message}");}catch(GroupDocsSignatureExceptionex){Console.WriteLine($"Common GroupDocsSignatureException: {ex.Message}");}catch(Exceptionex){Console.WriteLine($"Common Exception happens only at user code level: {ex.Message}");}finally{}}
More resources
GitHub Examples
You may easily run the code above and see the feature in action in ourΒ GitHub examples: