目前,我已经需要找到目录中的哪个PDF是“安全文档”。所有PDF 应该 不受抵押,并通过XPDF转换,但是事实并非如此。我如何扫描目录中的所有PDF,以找出它们是否得到保护?

有帮助吗?

解决方案

pypdf 支持解密PDF。它的pdffilereader课程 Isencrypted 属性。

import pyPdf
if pyPdf.PdfFileReader(open("file_name.pdf", 'rb')).isEncrypted:
    print "Rut ro, it's encrypted."
    # skip file? Write to a log?
else:
    print "We're clear."
    # Do stuff with the file.
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top