Get platform-specific Ghostscript executable name

master
Dan Howe 7 years ago
parent cf62a228c3
commit fa1fe9149d

@ -56,8 +56,14 @@ def pdf_unlock(pdf_file, overwrite=False):
if input_name.endswith(suffix): if input_name.endswith(suffix):
return return
# save as temporary file # Get name of Ghostscript executable
cmd_str = ('gs ' if os.sys.platform == 'win32':
exec_name = 'gswin64c'
else:
exec_name = 'gs'
# Create Ghostscript command string
cmd_str = ('{} '
'-dSAFER ' '-dSAFER '
'-dNOPAUSE ' '-dNOPAUSE '
'-dQUIET ' '-dQUIET '
@ -65,7 +71,7 @@ def pdf_unlock(pdf_file, overwrite=False):
'-sPDFPassword= ' '-sPDFPassword= '
'-sDEVICE=pdfwrite ' '-sDEVICE=pdfwrite '
'-sOutputFile="{}.pdf" ' '-sOutputFile="{}.pdf" '
'"{}.pdf"').format(output_name, input_name) '"{}.pdf"').format(exec_name, output_name, input_name)
with subprocess.Popen( with subprocess.Popen(
cmd_str, stdout=subprocess.PIPE, bufsize=1, cmd_str, stdout=subprocess.PIPE, bufsize=1,

Loading…
Cancel
Save