From 2aa5edf2acc79a57b89ce989ddf2cbcb792df427 Mon Sep 17 00:00:00 2001 From: Florian Zirker Date: Fri, 23 Feb 2024 18:35:00 +0100 Subject: [PATCH] fix pdf password script --- paperless/scripts/removePdfPassword.py | 8 ++++++++ 1 file changed, 8 insertions(+) mode change 100644 => 100755 paperless/scripts/removePdfPassword.py 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)