fix pdf password script

This commit is contained in:
Florian Zirker 2024-02-23 18:35:00 +01:00
parent a478052194
commit 2aa5edf2ac

8
paperless/scripts/removePdfPassword.py Normal file → Executable file
View file

@ -25,6 +25,7 @@ def read_passwords_from_file():
if not passwords:
print("Empty password file")
passwords.append("") # some PDFs are encrypted with empty password
return passwords
@ -58,6 +59,13 @@ if __name__ == "__main__":
doc_path = os.environ.get('DOCUMENT_WORKING_PATH')
if not doc_path:
doc_path = sys.argv[1]
if not doc_path:
print("Neither DOCUMENT_WORKING_PATH set nor document passed by parameter.")
sys.exit(1)
if not os.path.exists(doc_path):
print(f"Document {doc_path} not found.")
sys.exit(1)