From fa1fe9149df6dd80fd548181f81275e7f4d727fa Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Wed, 28 Mar 2018 10:03:20 +1100 Subject: [PATCH] Get platform-specific Ghostscript executable name --- scripts/pdf_unlock.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/pdf_unlock.py b/scripts/pdf_unlock.py index 9f77fb0..b89f898 100644 --- a/scripts/pdf_unlock.py +++ b/scripts/pdf_unlock.py @@ -56,8 +56,14 @@ def pdf_unlock(pdf_file, overwrite=False): if input_name.endswith(suffix): return - # save as temporary file - cmd_str = ('gs ' + # Get name of Ghostscript executable + if os.sys.platform == 'win32': + exec_name = 'gswin64c' + else: + exec_name = 'gs' + + # Create Ghostscript command string + cmd_str = ('{} ' '-dSAFER ' '-dNOPAUSE ' '-dQUIET ' @@ -65,7 +71,7 @@ def pdf_unlock(pdf_file, overwrite=False): '-sPDFPassword= ' '-sDEVICE=pdfwrite ' '-sOutputFile="{}.pdf" ' - '"{}.pdf"').format(output_name, input_name) + '"{}.pdf"').format(exec_name, output_name, input_name) with subprocess.Popen( cmd_str, stdout=subprocess.PIPE, bufsize=1,