I am trying to open PDF's that have an opening password and when I try to open them it tells me that the password is incorrect, however, when I validate manually the password is correct, could you please help me?
This is my code:
def remove_pdf_password(input_path, output_path, password):
pdf_reader = PyPDF2.PdfReader(input_path)
print(input_path)
pdf_writer = PyPDF2.PdfWriter()
pdf_reader.decrypt('9127621')
for page_num in range(len(pdf_reader.pages)):
pdf_writer.add_page(pdf_reader.pages[page_num])
with open(output_path, 'wb') as output_file:
pdf_writer.write(output_file)
print("Contraseña eliminada y PDF guardado en", output_path)
I validate manually the password is correct.