使用Python创建只读pdf文件 [英] Creating read only pdf file using Python

查看:274
本文介绍了使用Python创建只读pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否使用任何python模块,我们可以创建一个新的pdf文件或修改仅具有读取权限的现有pdf文件.我想禁用pdf文件的另存为"和另存为其他格式".(DRM内容.)

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.)

推荐答案

我不确定这是可移植的,但是您可以使用os.chmod:

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)

感谢: 在Python中将文件更改为只读模式

这篇关于使用Python创建只读pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆