开发者

Checking if a PDF file is password-protected

开发者 https://www.devze.com 2023-01-25 02:05 出处:网络
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 abo

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

精彩评论

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