9

This is my scenario:

I'm converting PDF files to PNG images calling Ghostscript by C#. This is the argument string I use:

-dNOPAUSE -dBATCH -dFirstPage=1 -q -r300   -sDEVICE=png256 -sOutputFile=...

But, in this way, when I call Ghostscript it shows a window where (before I've added -q) there were output messages.

I've tried adding -dNODISPLAY after -r300. But in this way Ghostscript doesn't work and doesn't create images.

Question: In which way can I suppress the output window?

Kurt Pfeifle
  • 82,396
  • 21
  • 237
  • 335
SamDroid
  • 561
  • 1
  • 8
  • 27

1 Answers1

18

If you want to run Win32/Win64 Ghostscript on the commandline without having it popping up a separate window (to display its <stdout> and <stderr> messages and allow you for <stdin> input typing), then use these binaries (depending on your version of your locally installed Ghostscript):

  • gswin32c.exe (note the added c for command/console)
  • gswin64c.exe (note the added c for command/console)

Do not use gswin32.exe or gswin64.exe! These are the versions which bring along their own popup windows...

Kurt Pfeifle
  • 82,396
  • 21
  • 237
  • 335
  • thank you, I was using gswin32.exe instead of gswin32c.exe. For others that have same problem, see also the nld answer at this question to hide console: http://stackoverflow.com/questions/836427/how-to-run-a-c-sharp-console-application-with-the-console-hidden – SamDroid Feb 05 '15 at 10:02
  • 1
    Can you post an example usage of how it is being called in c# ? gswin32.exe with parameters it works but when I switch gswin32.exe to gswin32c.exe at process.WaitForExit(); line it gets into infinite loops – user3079364 Apr 16 '18 at 19:32
  • I am still seeing a console window popup when using the c version... – A X Oct 24 '20 at 19:06