【问题标题】:Creating read only pdf file using Python使用 Python 创建只读 pdf 文件
【发布时间】:2017-05-12 18:34:46
【问题描述】:

是否有任何 python 模块使用我们可以创建一个新的 pdf 文件或修改现有的只有读取权限的 pdf 文件。我想禁用 pdf 文件的“另存为”和“另存为其他格式”。(DRM 的东西。)

【问题讨论】:

  • 哪些查看器程序的“另存为”和“另存为其他格式”选项?
  • 目前我正在尝试让 Adob​​e Reader 禁用“保存”、“另存为”“另存为其他”选项
  • 我怀疑没有自定义阅读器插件是可能的。

标签: python python-2.7 pdf pdf-generation rights-management


【解决方案1】:

我不确定这是否可移植,但您可以使用 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)

感谢: Change file to read-only mode in Python

【讨论】:

  • 虽然这可能会阻止程序提供“保存”选项,但它几乎不会阻止程序提供通常针对文件系统中不同文件的“另存为”选项。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-08-21
  • 2017-12-21
  • 2015-09-27
  • 1970-01-01
相关资源
最近更新 更多