[pdftex] MPS code that drives gv/acroread crazy

Marco Kuhlmann mk at mcqm.net
Sat Aug 24 16:55:18 CEST 2002

    Dear list members,

I am currently experiencing problems with a software (Functional
MetaPost, http://afavant.elte.hu/~wferi/funcmp/) that writes some
PS specials into the *.mps files it generates, breaking both gv
and Acrobat Reader.

Functional MetaPost is a Haskell frontend to MetaPost: It
generates MetaPost code which then is compiled into *.mps and can
be included into PDFTeX.  The inclusion works fine, and via
PDFLaTeX, I get a working PDF file for my thesis.  However, both
gv and Acrobat refuse to show some of the pages containing
illustrations.  I get the following error message:

****************Unknown operator: where
Error: /stackunderflow in --astore--
Operand stack:
   --dict:6/6(L)--   0   0   --nostringval--
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1   3   %oparray_pop   1   3   %oparray_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue   --nostringval--   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1035/1476(ro)(G)--   --dict:0/20(G)--   --dict:72/200(L)--   --dict:97/127(ro)(G)--   --dict:218/230(ro)(G)--   --dict:19/24(L)--   --dict:4/6(L)--   --dict:22/31(L)--   --dict:1/1(ro)(G)--
Current allocation mode is local
GNU Ghostscript 6.53: Unrecoverable error, exit code 1

This error seems to be caused by the following fragment of
PostScript code, which is automatically inserted into each *.mps
file generated:

/xdvi$run where {pop errordict begin /undefined {} bind def end} if
/fmp1 /fmp1 def /fmp8 /fmp8 def /fmp24 /fmp24 def
/bitline1 {gsave pop dup scale dup length 8 mul 1 true currentpoint translate
   [66.66666 0 0 66.66666 0 0] 4 index imagemask pop grestore} bind def
/bitline8 {gsave pop dup scale dup length 1 8 currentpoint translate
    [2.8 0 0 2.8 0 0] 4 index image pop grestore} bind def
/bitline24 {gsave pop dup scale dup length 3 idiv 1 8 currentpoint translate
    [2.777777 0 0 2.777777 0 0] 4 index false 3 colorimage pop grestore} bind def
/XDVIfshow  {findfont exch scalefont setfont show} bind def
/DVIPSfshow {exch gsave 72 TeXDict /Resolution get div -72 TeXDict
     /VResolution get div scale 1 DVImag div dup scale get cvx exec
     show grestore} bind def
   {/xdvi$run where {pop XDVIfshow} {DVIPSfshow} ifelse} def
/fshow { exch dup 
	  /fmp1 eq {bitline1}
		   {dup /fmp8 eq {bitline8}
				 {dup /fmp24 eq {bitline24}
	  ifelse}       ifelse}       ifelse} def

As my understanding of PostScript is rather, eh, limited... I
would be very grateful if you could help me fixing this problem.
What does this code do?  Can it be re-written into a form that
will go through gv and Acrobat Reader?  Is the problem a general
one, or will it only occur together with PDFTeX?  I could just
change Functional MetaPost to not automatically include this
code, but that would break some of its functionality.


PS. Sorry if this mail receives you twice; I was not subscribed
to list the first time I sent it.

More information about the pdftex mailing list