Search code examples
postscriptascii85

PostScript ASCII85Decode filter


I'm trying to use PostScript's ASCII85Decode filter. Adding the following line to my PS file works fine, i.e. the letters XYZ are shown correctly on the page:

200 300 translate 0 0 moveto (XYZ) show

I then ASCII85-encoded the above line using an online tool, and placed the below snippet containing the encoded string (as suggested in the PLRM) into my PS file at the same location as the previous line:

currentfile /ASCII85Decode filter cvx exec 
<~1,(C)1GCL*FE1f-F)59,AKWZL0Hb4NG%Gc6+=L>p=t(S8BQ&)%~>

The resulting PS file gives me the following error in the GSView console:

Error: /undefined in T
Operand stack:

Execution stack:
%interp_exit   .runexec2   --nostringval--   --nostringval--   --    nostringval--   2   %stopped_push   --nostringval--   --nostringval--   false   1   %stopped_push   1926   1   3   %oparray_pop   1925   1   3   %oparray_pop   1909   1   3   %oparray_pop   1803   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--
Dictionary stack:
--dict:1176/1684(ro)(G)--   --dict:0/20(G)--   --dict:83/200(L)--   --dict:139/150(L)--
Current allocation mode is local
Last OS error: No such file or directory

I would expect the ASCII85Decoder to decode the encoded string, and the letters 'XYZ' to appear on the page.

What am I doing wrong?


Solution

  • Well, the first problem is that you haven't selected a font, so internally exec is throwing an error. If you use this:

    200 300 translate 0 0 moveto /Helvetica findfont 20 scalefont setfont (XYZ) show
    

    it will work better. You haven't said which version of Ghostscript you are using (or which OS) but your string doesn't give an error for me. However encoding the string above to:

    1,(C)1GCL*FE1f-F)59,AKWZL0Hb4NG%Gc6+>68sCj'B3Bk(QoAnc-nAoDR/+>PVnF(8WpAS,ju
    F<GX9FCoH/F<Du6=^!6sF(fK9~>
    

    (NB there is a 0x0a following the ,ju)

    results in XYZ being drawn on the output.