Creating read only pdf file using Python

我是研究僧i 提交于 2019-12-14 04:19:50

问题


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



来源:https://stackoverflow.com/questions/41362682/creating-read-only-pdf-file-using-python

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