Window pops up when batch printing PDF with Ghostscript - windows

I'm using GS 9.15 to batch print some PDF's on a windows machine. This is the command I'm using:
gswin64 -dNoCancel=true -dBATCH -dNOPAUSE -dNOSAFER -q -sDEVICE=ljet4d -sOutputFile=%printer%[printer path] "[pdf path]"
Although this works a window pops up during the print and then closes.
Any way to hide it?

Use gswin64c (command line version) instead of gswin64 (windowed version).

Related

Is there a way to convert a ps file with ghostscript on Windows without access to the command prompt (cmd)?

I hope that I find the right words to explain my problem. I want to convert an adobe illustrator file to png on a Windows machine where I have no admin rights, no Adobe Illustrator and no access to the cmd.
On my Ubuntu machine I can easily use something like
gs -dNOPAUSE -dBATCH -dEPSFitPage -sDEVICE=png16m -r600 -sOutputFile=test.png ai.ai
But on the Windows Machine I could only install Ghostscript 9.5, which starts into a GUI with a prompt that says "GS>". I never used that, so I just thought that I could write something like
-dNOPAUSE -dBATCH -dEPSFitPage -sDEVICE=png16m -r600 -sOutputFile=test.png ai.ai
But then I get only error messages and after some reading I found out that this interpreter is something different where people can put thinks on a stack or so. Can I somehow use this GS interpreter to do what my gs on the Linux machine did from the shell?
Best regards
Martin
PS: Windows 10 machine, whatelse do you need?

Ghostscript command to finish a print job in interactive mode?

I am trying to build a shell service that prints PDF documents using Ghostscript running under Windows. The service should run a simple command via stdin with the filename of a PDF document and use the same printer and its settings as a context.
By default, Ghostscript starts in interactive mode. The idea is to use the same Ghostscript process rather than to run gswin64c.exe on each request to the service. Only for developing and testing, the Microsoft XPS Document Writer is used to get the result in the desired XPS file, which name is selected manually. That is why I use the Ghostscript device mswinpr2. At production environment, there will be another printer.
The command to start the Ghostscript process is as follows:
gswin64c.exe -dFitPage -dNOSAFER -dNOPAUSE -q setup_xps.ps
The Ghostscript code of setup_xps.ps:
mark
/NoCancel true % don't show the cancel dialog
/OutputFile (%printer%Microsoft XPS Document Writer)
/PageSize [114.0 85.0]
(mswinpr2) finddevice % select the Windows device driver
putdeviceprops
setdevice
Such a setup is the only way to set OutputFile to %printer%Microsoft XPS Document Writer: gswin64c.exe v9.54 does not recognize it correctly when passing through the command line (as a result, mswinpr2 opens the standard print dialog to choose a printer).
Then, to print a PDF document: (test.pdf) run.
However, the print job is left in the enqueuing state after. And the showpage command just adds a blank page to the output XPS document. It is seen when updating the printer's job queue.
The question is what PostScript or Ghostscript command (or another language) should be used to finish this print job (which closes the output XPS file gracefully), leaving in the interactive mode of the running Ghostscript process to execute further print commands like (test_2.pdf) run, (test_3.pdf) run and so on.

Batch files won't run when combined (quitting ghostscript in a batch file

I have two batch files, both simple commands. Both work fine if I double click their icon. I'd like to merge them.
Part 1 looks like this: (%1 is the incoming PostScript from RedMon)
"c:\program files\gs\gs9.14\bin\gswin64c.exe" -dBATCH -dNOPAUSE -dSTRICT -dSAFER -sDEVICE=jpeg -r300 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -o "c:\path\temp_label.jpg" %1
Part 2 looks like this:
convert -quality 99 -density 300 -crop 1240x1760+110+100 -chop 0x200+0+900 -rotate 90 "c:\path\temp_label.jpg" "c:\path\temp_label_edit.jpg"
composite -gravity center "c:\users\mary\documents\labels\temp_label_edit.jpg" "c:\path\new_shipping_label.jpg" "c:\path\temp_label_small.jpg"
convert -quality 99 -density 300 -resize 3059 "c:\path\temp_label_small.jpg" "c:\path\temp_label_resize.jpg"
imdisplay /p "c:\path\temp_label_resize.jpg"
mspaint "c:\path\temp_label_resize.jpg"
Part 1 is a ghostscript command that just makes a jpg file from the incoming postscript. It's called by RedMon (using redrun.exe) when I print and works fine. Part 2 is imagemagick that crops the image, adds it to another layer, and shows me the result as a file as well as directing it to another (real) printer.
When I run just the first part, it gives me the file automagically when I print. If I double click the icon for part 2, it works. But what I'd like to do, since we run this at least 12 times/day, is to have them run from a single batch file.
What it does: When I merge the two batch files, the original file from GS is generated correctly. But then I get a message from both imdisplay and paint that "...temp_label_resize.jpg cannot be found." But like I mentioned, if I run them separately, they work.
What I've tried:
Adding and eliminating -dBATCH et al. from the parameters passed to GhostScript
Putting pauses between the commands to give time to run, using the ping method
Keeping the files separate and calling them from a single file, i.e. 1.bat calls 2.bat and 3.bat. Same result.
Removing all variables except for %1 (code reflects this)
Putting a call to open the different file names immediately after creation: the only file that is created is the original temp_label.jpg
Run gswin64 rather than gswin64c - no glitches reported, still no imagemagick code executed.
Called convert from the cmd to ensure that I was getting the imagemagick's convert and not something else.
My assumption is that since the imagemagick files are never created there is a problem either with GhostScript ending or with my imagemagick code. However, my imagemagick code executes properly. Therefore, my guess is that GS isn't exiting properly. I'm probably missing something obvious, any help would be appreciated.
It seems that the PATH environment variable for redrun.exe is not the same as that when you start a command prompt. I would recommend you specify the path to each command in full, similar to what you have done for gswin64c.exe, e.g.
"c:\program files\gs\gs9.14\bin\gswin64c.exe" ....
"c:\program files\ImageMagick\bin\convert.exe" ....
etc..etc..
This way you can be 100% sure that you are running the correct executable.

how to invoke fonts dir in ghostscript

I am trying to create a PDF out of a text file with Courier as font and trying to use gswin32c.exe on Windows, but unnable to pass parameters correctly, I think. The gswin32c.exe is the Windows exe of Ghostscript.
Here is my command:
gswin32c.exe -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sFONTPATH="C:\Temp\Fonts2\" -sOUTPUTFILE="C:\Temp\Outputfile.pdf" A1401227.TXT
I don't get a output file, why? How can I trigger the Font, pass the fonts dir?
Not getting an output file is nothign to do with the presence or absence of fonts.
You appear to be sending a text file to GS, which it can't handle (unless this is hand-crafted PostScript).
Most likely you are generating an error, but because you have specified -dBATCH the application exits immediately after displaying it, so you can't see it. Try it without that switch.

Opening Mode(Initial View) for the PDF File is missing Using Ghostscript

To Enable the Fastwebview and PDF version to set 1.7 am using Ghostscript.
Input PDF is having the Opening Mode option, After execute the below command Output PDF is not set with the Opening mode.
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dFastWebView=true -dCompatibilityLevel=1.7 -sOutputFile=output.pdf input.pdf
Kindly let me know how to handle this.

Resources