munzirahangar commited on
Commit
3f40d81
·
verified ·
1 Parent(s): 27198d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -3,14 +3,14 @@ import pikepdf
3
  from io import BytesIO
4
 
5
  def remove_pdf_password(file, output_file_name, password_prefix, start_year, end_year):
6
- file_content = file.read()
7
 
8
  output_path = f"/content/{output_file_name}"
9
 
10
  for year in range(start_year, end_year + 1):
11
  password = f"{password_prefix}{year}"
12
  try:
13
- with pikepdf.open(BytesIO(file_content), password=password) as pdf:
14
  pdf.save(output_path)
15
  return output_path, f"Password '{password}' removed successfully."
16
  except pikepdf.PasswordError:
 
3
  from io import BytesIO
4
 
5
  def remove_pdf_password(file, output_file_name, password_prefix, start_year, end_year):
6
+
7
 
8
  output_path = f"/content/{output_file_name}"
9
 
10
  for year in range(start_year, end_year + 1):
11
  password = f"{password_prefix}{year}"
12
  try:
13
+ with pikepdf.open(BytesIO(file), password=password) as pdf:
14
  pdf.save(output_path)
15
  return output_path, f"Password '{password}' removed successfully."
16
  except pikepdf.PasswordError: