I am trying to save my password-protected PDFs into normal PDFs without a password, however I forgot some of the passwords to the password-protected PDFs. How can I unlock these PDFs without the password using Python?
I have already referred to some of the solutions in this other post:
/questions/28192977/how-to-unlock-a-secured-read-protected-pdf-in-python
However, the pikepdf solutions don’t work for me as using pikepdf.open(filename)
gives me an invalid password error, since no password was input.
I also tried using the method to use this other method suggested:
reader = PdfReader(file)
if reader.is_encrypted:
writer = PdfWriter()
for page in reader.pages:
writer.add_page(page)
with open(output_path, "wb") as output_pdf:
writer.write(output_pdf)
but I will get this error: FileNotDecryptedError: File has not been decrypted
1