I am scripting the creation/manipulation of PDF files so I am using gs
(Ghostscript). The problem I am having is that if I use a variable for the the options, gs
errors out.
The command that I am using which works is:
gs -sDEVICE=pdfwrite -dCompatabilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile="${ofile}" "${tfile}"
To make things a little easier (for me at least) to view and edit as needed, I assigned these options to a variable as such
local gsOPTS="-sDEVICE=pdfwrite -dCompatabilityLevel=1.4 -dPDFSETTINGS=/printer"
local gsFLAGS="-dNOPAUSE -dQUIET -dBATCH"
gs "${gsOPTS}" "${gsFLAGS}" -sOutputFile="${ofile}" "${tfile}"
When I do this, gs
errors out with Unknown device: pdfwrite -dCompatabilityLevel=1.4 -dPDFSETTINGS=/printer
I've tried enclosing the variables in quotes and without; no change. When I don't use the variables, it works fine. I use this technique all the time (i.e. with FFMPEG) with no issue. Is there something specific to gs
that is causing this problem?
I'm running macOS 10.15.6, Zsh version 5.7.1 and gs
version 9.52.