0

我正在使用redmon将 de output postscript我的 c#重定向.exe到处理。打印配置与我配置ghostscript的配置相同,但我通知了我的路径,而不是 ghost.exe路径。

在此处输入图像描述

要转换 PDF 中的后记,我使用ghostscript,代码如下

Stream content = Console.OpenStandardInput();
using BinaryReader standardInputReader = new BinaryReader(content);

using (FileStream standardInputFile = new FileStream(psFile, FileMode.Create, FileAccess.ReadWrite))
{
    standardInputReader.BaseStream.CopyTo(standardInputFile);
}
standardInputReader.Close();

string ghostScriptPath = @"C:\gs\gs9.52\bin\gswin64.exe";

String ars = @"-Ic:\gs\gs925\lib -dNOPAUSE -dBATCH -q -dSAFER -sDEVICE=pdfwrite -sOutputFile=teste.pdf psFile.ps";
Process proc = new Process();
proc.StartInfo.FileName = ghostScriptPath;
proc.StartInfo.Arguments = ars;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
proc.WaitForExit();

但是ghostscript总是抛出错误%%[ Error: undefined; 冒犯命令:Redmon ]%%

如果我使用 ghostscript 而不是我的程序一切正常,但如果我“拦截”,错误总是会发生。我记录了这两种情况的输出,但日志是相同的,如下所示。

完整的日志可以在这里看到

%%BeginResource: file Pscript_WinNT_ErrorHandler 5.0 0
/currentpacking where{pop/oldpack currentpacking def/setpacking where{pop false
setpacking}if}if/$brkpage 64 dict def $brkpage begin/prnt{dup type/stringtype
ne{=string cvs}if dup length 6 mul/tx exch def/ty 10 def currentpoint/toy exch
def/tox exch def 1 setgray newpath tox toy 2 sub moveto 0 ty rlineto tx 0
rlineto 0 ty neg rlineto closepath fill tox toy moveto 0 setgray show}bind def
/nl{currentpoint exch pop lmargin exch moveto 0 -10 rmoveto}def/=={/cp 0 def
typeprint nl}def/typeprint{dup type exec}readonly def/lmargin 72 def/rmargin 72
def/tprint{dup length cp add rmargin gt{nl/cp 0 def}if dup length cp add/cp
exch def prnt}readonly def/cvsprint{=string cvs tprint( )tprint}readonly def
/integertype{cvsprint}readonly def/realtype{cvsprint}readonly def/booleantype
{cvsprint}readonly def/operatortype{(--)tprint =string cvs tprint(-- )tprint}
readonly def/marktype{pop(-mark- )tprint}readonly def/dicttype{pop
(-dictionary- )tprint}readonly def/nulltype{pop(-null- )tprint}readonly def
/filetype{pop(-filestream- )tprint}readonly def/savetype{pop(-savelevel- )
tprint}readonly def/fonttype{pop(-fontid- )tprint}readonly def/nametype{dup
xcheck not{(/)tprint}if cvsprint}readonly def/stringtype{dup rcheck{(\()tprint
tprint(\))tprint}{pop(-string- )tprint}ifelse}readonly def/arraytype{dup rcheck
{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}forall(])
tprint}ifelse}{pop(-array- )tprint}ifelse}readonly def/packedarraytype{dup
rcheck{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}
forall(])tprint}ifelse}{pop(-packedarray- )tprint}ifelse}readonly def/courier
/Courier findfont 10 scalefont def end errordict/handleerror{systemdict begin
$error begin $brkpage begin newerror{/newerror false store vmstatus pop pop 0
ne{grestoreall}if errorname(VMerror)ne{showpage}if initgraphics courier setfont
lmargin 720 moveto errorname(VMerror)eq{userdict/ehsave known{clear userdict
/ehsave get restore 2 vmreclaim}if vmstatus exch pop exch pop PrtVMMsg}{
(ERROR: )prnt errorname prnt nl(OFFENDING COMMAND: )prnt/command load prnt
$error/ostack known{nl nl(STACK:)prnt nl nl $error/ostack get aload length{==}
repeat}if}ifelse systemdict/showpage get exec(%%[ Error: )print errorname
=print(; OffendingCommand: )print/command load =print( ]%%)= flush}if end end
end}dup 0 systemdict put dup 4 $brkpage put bind readonly put/currentpacking
where{pop/setpacking where{pop oldpack setpacking}if}if
%%EndResource

obs:我使用的是 Windows 10

4

1 回答 1

0

好吧,如果您查看您发布的文件,它会开始:

RedMon - Redirection Port Monitor
Copyright (C) 1997-2012, Ghostgum Software Pty Ltd.  All Rights Reserved.
2012-06-21  Version 1.9

get_filename_as_user sent: C:\Users\Marina\Desktop\teste.pdf
....
...
REDMON WritePort: about to write 4096 bytes to port.
%!PS-Adobe-3.0

之前的所有%!PS-Adobe内容都不是 PostScript,也不是由打印机驱动程序发送的。这一切都是由 RedMon 端口监视器发送的。然后输出以:

%%EOF

REDMON WritePort: OK  count=2489 written=2489
REDMON EndDocPort: starting

REDMON WriteThread: ending
%%[Page: 1]%%
%%[LastPage]%%
REDMON EndDocPort: process finished after 1 second

REDMON EndDocPort: 0 bytes written to printer
REDMON EndDocPort: ending

并且 %%EOF 之后的所有内容都不是 PostScript,而是来自端口监视器。由于所有这些都不能形成有效的 PostScript 程序,因此将其发送到 Ghostscript 会导致某种错误。

您需要弄清楚如何去除这些冗长的内容,只将 PostScript 语言程序发送到 Ghostscript。

恐怕我无法帮助您,我不知道您的应用程序是如何从 RedMon 接收数据的。

无论如何,这并不是一个真正的 Ghostscript 或 PostScript 问题。

于 2020-09-03T07:13:26.710 回答