I'm currently working on a project where pdf's can be decrypted after a successful api call that returns the password. I've browsed through SO and pdftron SDK but can't find a definitive solution on how to insert this password into the security handler.
Things I have tried:
None of the GetSecurityHandler()
methods seem to handle password insertion:
SecurityHandler handler = m_PdfDocument.GetSecurityHandler();
Takes a password string but throws error:
m_PdfDocument.InitStdSecurityHandler(pwd);
error: Message: Not a standard security handler. The custom filter needs to be registered.
Judging from the message I assumed I needed m_PdfDocument.InitSecurityHandler()
instead, but that method doesn't take a string, only int.
Anyone can bump me onto the right track ?
Thank you for sending the file. This file is encrypted using custom encryption. Your DRM. No PDF reader can open the file, but your own custom PDF reader.
To open the PDF with PDFNet, you need to find out how the file was encrypted in the first place, and essentially do the opposite. I assume the other team that did the encryption was also decrypting, for at least testing purposes?
It might as simple as following example 3 in our Encryption sample. In which case you just need to register under the filter name that the other team used. I think I know what that is, but won't post here, and will email you instead.
But for others, if the PDF was encrypted with a filter called "Frodo", then it would be
CreateDelegate frodo_del = new CreateDelegate(FrodoSecurityHandler.Create);
SecurityManagerSingleton.Instance().RegisterSecurityHandler("Frodo", new SecurityDescriptor("Frodo Security", frodo_del));