Ghostscript Skip Box Dialog - pdf

My problem is not with Ghostscript, its works fine.
The problem is that when I try to print, Ghostscipt process call to Print Driver and a confirmation is needed.
I have to print without box print dialog, similar to called Quick Print on Office package.
My print model is HP Professional P1102, Operative System W7, printer is connected from USB.
I am using next command on Windows cmd:
gswin64.exe -dNOSAFER -dNOPAUSE -dBATCH -dNOPROMPT -sDEVICE=mswinpr2 -sOutputFile="\\spool" "\\pdf_name.pdf"
Somebody have suggestions?
Thanks for all

gswin64.exe -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies=1 -sDEVICE=mswinpr2 -sOutputFile="\\\\spool\printername" "C:\pdf_name.pdf"
I tried this and it works without any prompt.
The printer name is after the \\spool\ string.

Related

GhostScript save the original file too

I created a virtual printer with the "Multi File Port Monitor" software and this virtual printer call the following Ghostscript:
"C:\GS\[version]\bin\gswin64c.exe" -r204 -dMinFeatureSize=1 -dInterpolateControl=-1 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dAlignToPixels=1 -dNOINTERPOLATE -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dDownScaleFactor=1 -sOutputFile="%f" -
The script creates an output file and it's ok, but I need to save the original file too.
What's the best way to do this?

When adding a -c option to a Ghostscript command the printer popup appears even though it has been suppressed

Consider the following ghostscript command invoked form the command line on windows.
"C:\Program Files\gs\gs9.23\bin\gswin64c.exe" -sDEVICE=mswinpr2 -dORIENT1=false -dNOPROMPT -dNOPAUSE -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dFIXEDMEDIA -dDEVICEWIDTHPOINTS=398 -dDEVICEHEIGHTPOINTS=157 -dNOPAGEPROMPT -dQUIET -dNumCopies=1 -sOutputFile="\\spool\BWLAB05" "c:\print\download\133679.pdf"
This command works great. The print comes out and there is no pop up box. Now I add the following.
-c "<</Orientation 2>>setpagedevice"
to the above command to make
"C:\Program Files\gs\gs9.23\bin\gswin64c.exe" -sDEVICE=mswinpr2 -c "<</Orientation 2>>setpagedevice" -c "quit" -dORIENT1=false -dNOPROMPT -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dFIXEDMEDIA -dDEVICEWIDTHPOINTS=398 -dDEVICEHEIGHTPOINTS=157 -dNumCopies=1 -sOutputFile="\\spool\BWLAB05" "c:\print\download\133679.pdf"
the print window appears. I have changed no other part of the command. What is causing this to happen? How can I stop the print window appearing?
The order of operands to Ghostscript is important. Especially when using the -c switch, which introduces PostScript to be executed.
Effectively you are running two commands here:
-sDEVICE=mswinpr2 -c "<</Orientation 2>>setpagedevice" -c "quit"
-dORIENT1=false -dNOPROMPT -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dFIXEDMEDIA -dDEVICEWIDTHPOINTS=398 -dDEVICEHEIGHTPOINTS=157 -dNumCopies=1 -sOutputFile="\\spool\BWLAB05" "c:\print\download\133679.pdf"
As soon as it hits the -c Ghostscript stops processing the command line, and runs the PostScript. At this point we have not yet encountered the -dNOPROMPT, and as you haven't (yet) set the printer, Ghostscript doesn't know what printer to use so , unsurprisingly, the printer popup appears.
Ghostscript carries on processing the remainder of the command line as PostScript until it reaches a -f, or in fact any switch beginning -. You haven't put a -f in there, but I would very strongly recommend that you do. You also don't need to put a secopnd -c, once you've started processing the command line as PostScript it continues, until you stop it. I also suspect that you really don't want the quit in there. That terminates the interpreter, which means the changes you've introduced via setpagedevice will be discarded, because the interpreter returns to the default state.
After processing the content of the -c, Ghostscript carries on and processes the remainder of the command line. This time there's a -dNOPROMPT so you don't get prompted.
I would expect that this:
"C:\Program Files\gs\gs9.23\bin\gswin64c.exe" -sDEVICE=mswinpr2 -dORIENT1=false -dNOPROMPT -dPrinted -dBATCH -dNOSAFER -q -dFIXEDMEDIA -dDEVICEWIDTHPOINTS=398 -dDEVICEHEIGHTPOINTS=157 -dNumCopies=1 -sOutputFile="\\spool\BWLAB05" -c "<</Orientation 2>>setpagedevice" -f "c:\print\download\133679.pdf"
would work much better. Note your initial command line has a duplicate NOPAUSE and specifies both NOPROMPT and NOPAGEPROMPT (you don't need NOPAGEPROMPT if you set NOPROMPT, and you don't need either if you set NOPAUSE).
Finally I would urge you not to use -dNOSAFER, while it currently has no effect (because that's the default setting) we will soon be making SAFER the default and setting -dNOSAFER will substantially reduce your security when running files.
You should really use -dSAFER right now. There are a number of CVEs against this, and proof of concepts circulating right now which can have undesirable effects on your computer (running arbitrary executables, opening, writing, deleting files etc) if you don't use -dSAFER. If you don't know why you want -dNOSAFER, then use -dSAFER instead.
Oh, you should also upgrade to the current version, 9.27, the version you are using is a year old.

How to merge all PDF's in a directory with ghostscript

How can I read the files contained in the directory d:\ with batchscript not one by one files like that. I have tried the following:
#echo off
"C:\Program Files\gs\gs9.25\bin\gswin32c.exe" -sDEVICE=pdfwrite -dCompatibilityLevel=1.3 -dPDFSETTINGS=/printer -dColorImageResolution=90 -dAutoRotatePages=/None -dBATCH -dNOPAUSE -sOutputFile=d:\d\koran.pdf *d:\a\01.pdf d:\a\02.pdf d:\a\03.pdf d:\a\04.pdf d:\a\05.pdf d:\a\06.pdf d:\a\07.pdf d:\a\08.pdf d:\a\09.pdf d:\a\10.pdf d:\a\11.pdf d:\a\12.pdf d:\a\13.pdf d:\a\14.pdf d:\a\15.pdf d:\a\16.pdf d:\a\17.pdf d:\a\18.pdf d:\a\19.pdf d:\a\20.pdf d:\a\21.pdf d:\a\22.pdf d:\a\23.pdf d:\a\24.pdf*
exit
Ghostscript doesn't 'merge' PDF files. It creates new PDF files by interpreting the contents of its input, this is not the same thing. You should read the documentation here
You haven't said what the problem is with the command you have tried, its going to be hard to help you if you don't do that.
The most likely problem is that you have put * characters at the start and end of the input filenames. Ghostscript itself doesn't match wildcards, it expects you to tell it each file you want to process individually. So in order to process a directory of files is to first get a list of all the files, and then tell Ghostscritp to use each of those files in turn.
You can use the Ghostscript #filename syntax (documented here)to tell Ghostscript to use the contents of a file as if it were the command line.
So all you need to do is come up with a shell script which will write the filenames from a folder into a file. That's not a Ghostscript question, and depends totally on the operating system you are using.
For Windows something like:
dir /B *.pdf >> files.txt
gswin32c -sDEVICE=pdfwrite -dBATCH -dNOPAUSE -sOutputFile=\temp\out.pdf #files.txt
del files.txt
might be sufficient for your needs.
I could not make it work using "files.txt" but I am using this and everything works just fine.
gswin64c -sDEVICE=pdfwrite -dBATCH -dNOPAUSE -sOutputFile="out.pdf" (Get-ChildItem -Path .\*.pdf)
You can execute like below:
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=merged.pdf *.pdf
Reference:
https://gist.github.com/moaazsidat/b94185e9cfdba9e3cfb5bc90407e6397

no output file generated when using Ghostscript to convert PDF to TIFF

Here is the command I use:
gs -r300 -q -dNOPAUSE -sDevice=tiffgray -sOutputFile=sample1.tiff sample1.pdf -c quit
I don't see sample1.tiff in my current working directory. I'm running OS Mavericks.
Try running without -q so that the messages aren't suppressed, Ghostscript is probably trying to tell you what's wrong.

best solution for sending fax in asterisk

I want to write a script for sending a fax with Asterisk,
but many faxes have an error when sending.
I use Spandsp for Asterisk and I use gs for converting PDF to TIFF.
I think it may be a problem of converting PDF to TIFF.
I very try to convert's command for this, such as:
gs -q -sDEVICE=tiffg3 -dNOPAUSE -dBATCH -sOutputFile=Sample.pdf.tif -f Sample.pdf
/usr/bin/acroread -toPostScript -size a4 <filename>
/usr/bin/gs -q -sDEVICE=tiffg32d -sPAPERSIZE=a4 -r204x196 -sOutputFile=<outputfile> -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dNOPAUSE -dBATCH -f <inputfile.ps>
and I tested anyways into link for converting, but it doesn't work fine, and most of sending fax have issue.
Also, I have another problem in answer detection beep in my Asterisk when the trunk with Newrock gateway(analog), this is cause some fax doesn't send correctly!
Check hylafax code. It have working script
I use code like this:
gs -sDEVICE=tiffg3 -sPAPERSIZE=$pagesize -r204x196 -dNOPAUSE -dNOPAGEPROMPT -dBATCH -sOutputFile=dest.tif \
-c save pop -f input.pdf -c quit
But actualy it doesn't metter. More important how setup your routes/codecs.
Other problem is for sure offtopic here. You have read more books or hire expert.