Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.4k
  • 205
  • 1.8k
  • 2.3k
added 1 character in body
Source Link
Allan
  • 1.1k
  • 5
  • 16
  • 34

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 donedon'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.

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 done 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.

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.

Source Link
Allan
  • 1.1k
  • 5
  • 16
  • 34

Using variables for Ghostscript options/flags causes errors

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 done 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.