开发者

Checking if a PDF file is password-protected

I know of several tools/libraries that can do this but I want to know if this is possible with just opening up the file开发者_高级运维 as a text file and looking for a keyword.


You could do this in about 4 lines of Python with the slate package:

>>> import slate
>>> with open('file.pdf, 'rb') as f:
...     doc = slate.PDF(f, 'password')
>>> 'keyword' in doc.text()
True 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜