Spaces:
Build error
Build error
Update app.py
Browse files
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 |
-
|
| 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(
|
| 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:
|