I'd like to create a read only PDF. I've written and executed the following code :
from PyPDF2.pdf import PdfFileReader, PdfFileWriter
# create an empty pdf writer
writer = PdfFileWriter()
writer.encrypt("user_pwd", "owner_pwd")
output = open(r"C:\Temp\TestFileLock.pdf", "wb")
writer.write(output)
An error occured in the encrypt function and generate the following traceback :
File "C:\Program Files (x86)\Python27\lib\site-packages\PyPDF2\pdf.py", line 229, in encrypt
U, key = _alg35(user_pwd, rev, keylen, O, P, ID_1, False)
File "C:\Program Files (x86)\Python27\lib\site-packages\PyPDF2\pdf.py", line 2140, in _alg35
key = _alg32(password, rev, keylen, owner_entry, p_entry, id1_entry)
File "C:\Program Files (x86)\Python27\lib\site-packages\PyPDF2\pdf.py", line 2051, in _alg32
m.update(id1_entry.original_bytes)
AttributeError: 'str' object has no attribute 'original_bytes'
Hi,
I'd like to create a read only PDF. I've written and executed the following code :
An error occured in the encrypt function and generate the following traceback :