是否有可能和方法在 python 中加密 PDF 文件? 一种可能性是压缩 PDF,但还有另一种可能性吗? 感谢您的帮助 问候 菲利克斯
最佳答案
您可以使用 PyPDF2 :
from PyPDF2 import PdfFileReader, PdfFileWriter
with open("input.pdf", "rb") as in_file:
input_pdf = PdfFileReader(in_file)
output_pdf = PdfFileWriter()
output_pdf.appendPagesFromReader(input_pdf)
output_pdf.encrypt("password")
with open("output.pdf", "wb") as out_file:
output_pdf.write(out_file)
有关详细信息,请查看 PdfFileWriter
docs .
关于python - 在 python 中加密 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43475295/