在Python中使用PyPDF2将PDF写入密码以保护PDF时出现问题

时间:2018-12-12 13:25:58

标签: python pypdf2

这是代码

import PyPDF2,os
output = PyPDF2.PdfFileWriter()
input_stream = PyPDF2.PdfFileReader(open("/root/Desktop/temp_dir/Mr praveen.pdf", "rb"))

for i in range(0, input_stream.getNumPages()):
        output.addPage(input_stream.getPage(i))

outputstream = open("/root/Desktop/name.pdf", "wb")
output.encrypt("mani", use_128bit=True)
output.write(outputstream)
outputStream.close()

运行此代码时,出现错误

提高utils.PdfReadError(“无法在字节%s的流之后找到'endstream'标记。”%utils.hexStr(stream.tell())) PyPDF2.utils.PdfReadError:在字节0xa721的流之后找不到'endstream'标记。 请帮助我。

0 个答案:

没有答案
相关问题