user2366975
user2366975

Reputation: 4720

How to use Ghostscript without opening shell?

Using gswin32c.exe on Windows 7, and starting next command from a .bat-file, I can convert a pdf to a image using ghostscript. However, the shell is

a) opened and

b) not closed after finishing.

C:\Users\me\desktop\gswin32c.exe -dQuiet -q -dNOPAUSE -sDEVICE=jpeg -r200 -sOutputFile=C:\Users\me\desktop\converted.jpg C:\Users\me\desktop\test.pdf

How can I call this command silently in the background, without showing the shell?

Ultimately, I want to use this command from a Qt-application without a bat-file. There I am using QProcess to execute the command, but the effect is the same.

Upvotes: 0

Views: 743

Answers (1)

KenS
KenS

Reputation: 31207

You can use the Ghostscript API and simply load the DLL.

The only way, under Windows, to run the supplied binary without a command shell that I'm aware of is to make it a service and schedule it. In any event I think its a bad idea, as your user can be left with Ghostscript executing and having to use Task Manager to kill it. (which they won't do, because they don't realise its running....)

NB you haven't set -dBATCH, which means that Ghostscript is still executing (ie its not finished, its waiting for more input from you). If you do that I believe you will find that the window will close after completion.

Upvotes: 1

Related Questions