How do I deal with “Compressed object is corrupt” when processing password protected PDF?

Q:

While attempting to convert to XOD some PDF documents which are password protected the function is returning the following message.

“Compressed object is corrupt”

Perhaps this message could indicate that the file is password protected if possible or it could be that I have done something in error.

A:

This is most likely the case. You can detect password protected files with pdfdoc.InitSecurityHandler(), which will return false if the file needs password.

You can provide password with pdfdoc.InitStdSecurityHandler(“pass”) as shown in EncTest sample project (snippet #2).

http://www.pdftron.com/pdfnet/samplecode.html#EncTest