diff --git a/paperless/scripts/removePdfPassword.py b/paperless/scripts/removePdfPassword.py old mode 100644 new mode 100755 index 4931931..57942e6 --- a/paperless/scripts/removePdfPassword.py +++ b/paperless/scripts/removePdfPassword.py @@ -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)