I'm trying it for some hours and can't get a good result. I need to print a PDF document by the command line and I chose Ghostscript to do the hard work. I'm creating a file named config.cfg with my parameters and passing it to Ghostscript. My Ghostscript installation path is C:\Program Files\gs\gs9.15\bin
and I'm using the executable gswin64c
for the tests. My configuration file is the following:
config.cfg
"C:\pdf\pdf\type_theory.pdf"
-colour
-noquery
-printer "Work Printer"
-ghostscript "C:\Program Files\gs\gs9.15\bin\gswin64c.exe"
-all
-portrait
-copies 1
and I'm calling, via command line:
gswin64c -config "C:\\pdf\\pdf\\config.cfg"
But I'm receiving the following error in output:
GPL Ghostscript 9.15 (2014-09-22)
Copyright (C) 2014 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /undefined in C:\\pdf\\pdf\\postscript.cfg
Operand stack:
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:1188/1684(ro)(G)-- --dict:0/20(G)-- --dict:77/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
I can understand that it is missing a file by its last sentence, but I can't figure what it is. Can somebody help me to find my error?
You haven't selected a device, so you'll get the default device, which is the display. If you want to print to a printer, you will need the mswinpr2 device. So -sDEVICE=mswinpr2
I'm not at all sure where you got the contents of config.cfg, is this supposed to be a command line for gsprint by any chance ? The options make some sense for gsprint, they don't make any sense at all for Ghostscript. Ghostscript switches are mostly either -s or -d there are comparatively few which are simply -
The error doesn't tell you its missing a file, that would be 'undefinedfilename' its telling you that something in 'postscript.cgfg' is undefined. PostScript is a programming language, and this is the interpreter telling you your program has an error. -color is probably the problem.