Following example demonstrates how to handle incorrect password exception.
// initialize LoadOptions with incorrect Password
LoadOptionsloadOptions=newLoadOptions();loadOptions.setPassword("1");Signaturesignature=newSignature("ProtectedPwd.pdf",loadOptions);try{QrCodeSignOptionsoptions=newQrCodeSignOptions("JohnSmith");options.setEncodeType(QrCodeTypes.QR);options.setLeft(100);options.setTop(100);// try to sign document to file, we expect for PasswordRequiredException
signature.sign(outputFilePath,options);System.out.print("\nSource document signed successfully.\nFile saved at "+outputFilePath);}catch(IncorrectPasswordExceptionex){System.out.print("HandlingIncorrectPasswordException: "+ex.getMessage());}catch(GroupDocsSignatureExceptionex){System.out.print("Common GroupDocsSignatureException: "+ex.getMessage());}catch(java.lang.RuntimeExceptionex){System.out.print("Common Exception happens only at user code level: "+ex.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.