python: pdf - set password protected print, copy, paste options?

烂漫一生 提交于 2019-12-10 21:05:33

问题


Hi I'm looking for a python lib that will allow me to set password protected print, copy, paste options on some existing pdfs

I looked at the reportlab pdfencrypt module: this has exactly the options I need, but the open source version is heavily restricted - cant even set a real password, and the license is not an option (over £1000/year) - this will be relatively low volume (< 1000 docs processed per year), and the client is a non-profit organisation

any suggestions greatly appreciated!


回答1:


Have you tried The PDF Toolkit, command-line interface (pdftk)?

http://www.pdflabs.com/docs/pdftk-cli-examples/




回答2:


Laaate answer, but I wanted to start contributing...

in the pdf.py file, in the encypt() method, change the flag:

    # permit everything:
    P = -1

to:

    # prevent everything:
    P = -3904

This will prevent all features beyond simple viewing. Be sure to pass in a different owner password.




回答3:


PyPDF allows encrypting PDF files.



来源:https://stackoverflow.com/questions/13109867/python-pdf-set-password-protected-print-copy-paste-options

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!