Is there any python module using that we can create a new pdf file or modify the existing pdf file which have only read permission. I want to disable the "Save as" and "Save as to other formats" for the pdf file.(DRM things.)
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I'm not sure this is portable, but you could use os.chmod:
import os
from stat import S_IREAD, S_IRGRP, S_IROTH
filename = "yourfile.pdf"
# Open the file and write your stuff to the file etc...
os.chmod(filename, S_IREAD|S_IRGRP|S_IROTH)
Thanks to: Change file to read-only mode in Python