我尝试了几个小时并且无法取得好成绩。我需要通过命令行打印PDF文档,然后选择Ghostscript来完成这项工作。我用我的参数创建了一个名为 config.cfg 的文件,并将其传递给Ghostscript。我的Ghostscript安装路径为C:\Program Files\gs\gs9.15\bin
,我使用可执行文件gswin64c
进行测试。我的配置文件如下:
的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
我正在通过命令行调用:
gswin64c -config "C:\\pdf\\pdf\\config.cfg"
但我在输出中收到以下错误:
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
我可以理解它的最后一句错过了一个文件,但我无法弄清楚它是什么。有人可以帮我找到我的错误吗?
答案 0 :(得分:1)
您尚未选择设备,因此您将获得默认设备,即显示器。如果要打印到打印机,则需要mswinpr2设备。所以-sDEVICE = mswinpr2
我不确定你在哪里获得了config.cfg的内容,这应该是gsprint的命令行吗?这些选项对gsprint有一定意义,它们对Ghostscript根本没有任何意义。 Ghostscript开关大多是-s或-d,相对较少的只是 -
错误并没有告诉你它丢失了一个文件,那就是'undefinedfilename'它告诉你'postscript.cgfg'中的某些东西是未定义的。 PostScript是一种编程语言,这是解释器告诉您程序有错误。 - 颜色可能是问题。