# Solved: Ghostscript not working in Windows XP



## andreyman3d2k (Oct 28, 2009)

Hello all!

Not sure if this forum is the right place, but it might be.

I've been having a problem with ghostscript on for a web project I am doing.. Couldn't figure it out, but now I see the problem -- Everything I type into the ghostscript console gives the "/undefined in [whatever I type]" error.

For example:

-sDEVICE=jpeg -sOutputFile=foo.jpg foo.ps

gives:

Error: /undefined in -sDEVICE=Jpeg

I am running this on Windows XP, Ghostscript 8.70 (tried downloading earlier version 8.63, same result)

What's going on? Tremendous gratitude for any help!

Andrey


----------



## lotuseclat79 (Sep 12, 2003)

andreyman3d2k said:


> Hello all!
> 
> Not sure if this forum is the right place, but it might be.
> 
> ...


Hi Andrey,

From a Run Command window, suggest you try running: gs -h

Ghostscript may be built to use many different output devices. To see
which devices your executable includes, run "gs -h". Unless you spec‐
ify a particular device, Ghostscript normally opens the first one of
those and directs output to it, so if the first one in the list is the
one you want to use, just issue the command

gs myfile.ps

You can also check the set of available devices from within
Ghostscript: invoke Ghostscript and type

devicenames ==

but the first device on the resulting list may not be the default

Note: The above information is from the man page for ghostscript on a Linux system, but the gs executable in Windows, i.e. gs.exe, might need to be substitued for gs when you run the command.

-- Tom


----------



## andreyman3d2k (Oct 28, 2009)

Thanks for the reply Tom! I've been getting absolutely nowhere, and out of like a dozen forums you gave the first meaningful response!

I did what you said, and saw the list of devices. I think the one i want is Jpeg. How would I switch to it? here is the command I am trying to run:

-sDEVICE=jpeg -dNOPAUSE -dBATCH -sOutputFile='[outputpath]' '[inputpath]'

I got that from a script online, but it was written for linux... Does that switch not work?


----------



## lotuseclat79 (Sep 12, 2003)

Hi Andrey,

I am attaching the man page for ghostscript on Ubuntu Linux. Take a look at it to see if you can forumlate a solution. My time is limited, and I know you will figure it out! 

I'll check back to this thread later tonight to see how it goes. I just ran the command: gs -h
and I saw jpeg in the output as a valid device, so if your output shows jpeg then you can do it, otherwise, I wouldn't think so.

Note: The format of the ghostscript command (gs) you are trying to do is:
$ gs -sDEVICE=jpeg -dNOPAUSE -dBATCH -sOutputFile='[outputpath]' '[inputpath]'
where the $ is the prompt (assuming you are running it from the run command - the $ is not present, but is in a command line environment in Ubuntu if that is where you run the command from a regular user account.

-- Tom


----------



## andreyman3d2k (Oct 28, 2009)

Hi Tom

I think I can't use the ghostscript prompt directly... even when I type -h i get nothing

currently I am trying to use the command prompt, but still with no cigar.

I type into the command prompt:

"C:/Program Files/gs/gs8.70/bin/gswin32.exe" -sDEVICE=jpeg -dNOPAUSE -dBATCH -sOutputFIle "C:/Documents and Settings/Andrey/Desktop/pdftest/book5.jpg" "C:/Documents and Settings/Andrey/Desktop/pdftest/book5.pdf"

It returns: Error: /undefinedfilename in "C:/Documents and Settings/Andrey/Desktop/pdftest/book5.jpg"

Operand stack... etc.

All the paths are correct.

I was thinking that maybe it is adding the path to some pre-defined directory... or maybe it doesn't have permissions?? it's weird.

I read that ghostscript treats anything where there is : as the second character as an absolute path, and my command fits the bill, since C:/... has a semicolon in the second position. So that should be fine.

Thanks again for all your help.

Andrey


----------



## andreyman3d2k (Oct 28, 2009)

Ack I had a filename wrong! But now that I've fixed it, the error has become even stranger. Can't even type it -- attaching a screenshot.

Is it a fish looking through a window? or is it cursing at me?


----------



## andreyman3d2k (Oct 28, 2009)

Sorry, screwed up the attachment. Should work now.


----------



## lotuseclat79 (Sep 12, 2003)

andreyman3d2k said:


> Hi Tom
> 
> I think I can't use the ghostscript prompt directly... even when I type -h i get nothing
> 
> ...


Hi Andrey,

I don't understand why some items in the command line are enclosed in quotes? Certainly not the command itself, i.e. "C:/Program Files/gs/gs8.70/bin/gswin32.exe".

I would recommend de-quoting your full command line and then attempt to rerun it, in the Run Command window or figure out how to get a window for using command lines, and then insert the full command line you wish to execute after the prompt - may be a $.

-- Tom


----------



## andreyman3d2k (Oct 28, 2009)

Okay, I will try without quotes at work tomorrow, thanks. I thought the quotes were required on the command line when the path has two words in it, like 'Program Files'. The command prompt seems to find the directory for ghostscript, so "C:/Program Files/gs/gs8.70/bin/gswin32.exe" works. Will try to remove the quotes in the commands passed to ghostscript, maybe that will work. The error message is so cryptic. What can those symbols mean?


----------



## IMM (Feb 1, 2002)

This comment is slightly off-topic -- but until you get used to it (and assuming you aren't running from a batch file or similar) you might want to try a GUI for ghostscript such as GSView
http://www.ghostgum.com.au/


----------



## andreyman3d2k (Oct 28, 2009)

Hi IMM, thanks for the reply. I actually tried that already, downloaded GSview. Everything works fine there -- I can select a PDF and make it into a jpeg. The problem is that I need it to be done via command line, because it is going to be called by a PHP script on a web page, not done manually.


----------



## andreyman3d2k (Oct 28, 2009)

GOT IT TO WORK!!!

I was missing the = sign after -sOutputFile

Thanks so much for your help Tom!

Andrey


----------

