79645899

Date: 2025-05-30 17:56:58
Score: 2
Natty:
Report link

I mentioned in my original post that I thought that ps2pdf was a script that called gs. This turns out to be correct. ps2pdf is the generic script; there are 3 or 4 other scripts that get called if you want your output to be PostScript Level 2, for example. But on my system the script that actually does something is ps2pdfwr:

#!/bin/sh
# Convert PostScript to PDF without specifying CompatibilityLevel.

# This definition is changed on install to match the
# executable name set in the makefile
GS_EXECUTABLE=gs
gs="`dirname \"$0\"`/$GS_EXECUTABLE"
if test ! -x "$gs"; then
    gs="$GS_EXECUTABLE"
fi
GS_EXECUTABLE="$gs"

OPTIONS="-P- -dSAFER"
while true
do
    case "$1" in
    -?*) OPTIONS="$OPTIONS $1" ;;
    *)  break ;;
    esac
    shift
done

if [ $# -lt 1 -o $# -gt 2 ]; then
    echo "Usage: `basename \"$0\"` [options...] (input.[e]ps|-) [output.pdf|-]" 1>&2
    exit 1
fi

infile="$1";

if [ $# -eq 1 ]
then
    case "${infile}" in
      -)        outfile=- ;;
      *.eps)    base=`basename "${infile}" .eps`; outfile="${base}.pdf" ;;
      *.ps)     base=`basename "${infile}" .ps`; outfile="${base}.pdf" ;;
      *)        base=`basename "${infile}"`; outfile="${base}.pdf" ;;
    esac
else
    outfile="$2"
fi

# We have to include the options twice because -I only takes effect if it
# appears before other options.
exec "$GS_EXECUTABLE" $OPTIONS -q -P- -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sstdout=%stderr "-sOutputFile=$outfile" $OPTIONS "$infile"

So, from my original post, this worked

$ ps2pdf testfile.ps

but this did NOT work

$ gs -sDEVICE=pdfwrite -o testfile.pdf testfile.ps

Based on my examination of the script ps2pdfwr above, I tried this, which DID work:

gs -P- -dSAFER -q -P- -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sstdout=%stderr \

-sOutputFile=testfile.pdf testfile.ps

I don't understand which of the switches did the trick, but I guess I'm satisfied that gs can indeed substitute fonts if you give it the right switches.

KenS - Thanks for your comments. In researching this problem over the past few days I kept running into comments saying that you had to modify gs's Fontmap file to include any new font you wanted to use, and supply the full path to the modified Fontmap file as a switch to your gs command. That all actually seems to be unnecessary -- though I suppose it is possible that ghostscript modifies its Fontmap file as needed as the user specifies a new system font.

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Blacklisted phrase (1): did NOT work
  • Blacklisted phrase (1): to comment
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Paul Dulaney