How do I run PDF/A conversion and validation of password protected PDFs?

Q: We came across to a problem related to PDF/A conversion and
validation ( and it
deals with password protected PDF files. There is no way to learn from
PDFACompliance that user provided a wrong password to access file
contents for conversion/validation. We do not think that it is a good
idea to provide user with this information through the array of PDF/A
compliance issues. The best way would be to set value of some class
member, like - isGoodPassword = false.
A: PDFACompliance class assumes that the provided password is correct
(and will throw an exception otherwise).

To obtain a correct password from a user you could first open a
document using PDFDoc class. If doc.InitSecurityHandler() returns
false, it means that the user needs to provide 'open' password. In
this case you can call doc.InitStdSecurityHandler() any number of
times with different passwords. After obtaining the valid password
(i.e. when InitStdSecurityHandler() returns true) you can close the
document and use PDFACompliance with the correct password. For

PDFDoc doc = new PDFDoc("my.pdf");
if (!doc.InitSecurityHandler()) { // need pass
  for(int count=0; count<3;count++) {
       ... get password
  if(doc.InitStdSecurityHandler(password)) {
    success=true; // The password is correct
  else if(count<3) {
    // The password is incorrect, please try again.
if(!success) {
   // Document authentication error...

... Now use password to open "my.pdf" using PDFAComplaince