bug-ghostscript
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Windows postscript outputs %%[ LastPage ]%% & other garbage with ghostsc


From: Marek Peca
Subject: Windows postscript outputs %%[ LastPage ]%% & other garbage with ghostscript -- solution
Date: Wed, 20 Mar 2002 17:33:02 +0000 ( )

Hello,

many people asked, how to avoid ghostscript (in most cases used with samba
and some kind of lpr* software) to print messy output of Windows' crazy
postscript, such as %%[ LastPage ]%%, %% [ Page: 1 ]%% &c. Excuse me, if
thi question have been already answered here.

The problem is, that Windows' PSCRIPT.DRV's output contains a lot of
status-printing commands, which probably have to show the progress of
printing and encountered errors, and looks like this:

(%%[ LastPage ]%%)  =

There is used the "=" command, which pops the top object on the stack and
prints it on the _standard_output_. The problem is, that ghostscript sends
this standard output to its real standard output, even if OutputFile is
set to -, so the result is mixed.

The solution: I don't know, how to supress the postscript-stdout in
ghostscript, but I've succesfully did followig hack: we need to redefine
"=" command to do nothing (and also don't forget to pop that great nice
thing from the stack):

/= { pop } def

So, it's sufficient to put this definition to the Windows' generated
postscript file (or insert it to the stream). Probably the most correct
place, where to put this, is the prolog; so we can sed the input, search
"%%BeginProlog" and put the def. after it. But -- when we don't need to
process the postscript in other ways, than print it, we can put that def.
safely at the beginning of the file/stream. E.g., I wrote following
script /usr/bin/gswin:

#!/bin/sh
##########HERE#IS#THE#SCRIPT##########
(/usr/bin/printf "%%!\n/= { pop } def\n"; cat) | /usr/bin/gs $@
######################################

Which inserts "%!\n/= { pop } def" at the start of stream and invoke gs
with parameters. I replaced gs with gswin in my printer filters (in my
case, this is the line from /etc/magicfilter/ljet4-filter:
0       %!              filter  /usr/bin/gswin  -q -dSAFER -dNOPAUSE -r600 \
-sDEVICE=ljet4 -sOutputFile=- - -c quit
). It should work with other spooling systems, only need is to patch their
input filters.


Regards,
Marek P.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]