python: pdf - set password protected print, copy,

2019-07-03 16:38发布

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!

3条回答
神经病院院长
2楼-- · 2019-07-03 17:14

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楼-- · 2019-07-03 17:15

PyPDF allows encrypting PDF files.

查看更多
迷人小祖宗
4楼-- · 2019-07-03 17:30

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

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

查看更多
登录 后发表回答