Q:
Some of our PDF files are protected with custom DRM encryption (e.g. Adobe LiveCycle Rights security).
How can I detect PDF files protected with Adobe LiveCycle Rights security ?
A:
You can use the following snippet to detect files with custom encryption (including Adobe DRM):
PDFNet.Initialize();
Try {
using (PDFDoc doc = new PDFDoc(“my.pdf”))
{
try {
if (!doc.InitSecurityHandler()) {
Console.WriteLine(“Document authentication error…”);
}
}
catch(PDFNetException e) {
Console.WriteLine(e.Message);
Console.WriteLine(doc.GetTrailer().Get(“Encrypt”).Value().Get(“Filter”).Value().GetName());
}
}
}
catch (PDFNetException e) {
Console.WriteLine(e.Message);
}
The output will be:
Exception: Requested security handler was not found.
Adobe.APS
So doc.InitSecurityHandler() will throw an exception if there is no matching security handler for a given filter name (in this case “Adobe.APS”).
For this to work you may need to use the latest PDFNet build (v.5.8.2 or higher):