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,