Issue 31: Type1CParser fails in gs with /typecheck in --closefile-- [patch]
Status:  Fixed
Owner: ----
Closed:  Feb 2011
Reported by william.bader@gmail.com, Mar 25, 2010
What steps will reproduce the problem?

1.python pdfsizeopt.py alphabet.pdf

I have attached the file.  It is 14 KB.

What is the expected output? What do you see instead?

info: This is pdfsizeopt.py rUNKNOWN.
info: loading PDF from: alphabet.pdf
info: loaded PDF of 14224 bytes
info: separated to 16 objs
info: found 0 Type1 fonts loaded
info: found 1 Type1C fonts loaded
info: writing Type1CParser (10807 font bytes) to: pso.conv.parse.tmp.ps
info: executing Type1CParser with Ghostscript: gs -q -dNOPAUSE -dBATCH
-sDEVICE=nullpage -sDataFile=pso.conv.parsedata.tmp.ps -f pso.conv.parse.tmp.ps
Type1CParser: using interpreter GPL Ghostscript 871 20100210
Error: /typecheck in --closefile--
Operand stack:
   --nostringval--   --dict:3/3(L)--   --nostringval--   --dict:1/1(ro)(L)--

What version of the product are you using? On what operating system?

pdfsizeopt "by pts@fazekas.hu at Sun Mar 29 13:42:05 CEST 2009"
gs8.71
Fedora 8 Linux

Please provide any additional information below.

The patch below fixed the problem for me.  I inserted debug code and calls
to pstack and found that LoadCff leaves a dictionary on the stack.  The
patch pops the dictionary.  Comments in LoadCff mention problems that
depend on the version of gs, so I made the pop conditional on finding a
dictionary.

William
williambader@hotmail.com

--- pdfsizeopt/pdfsizeopt.py-   2010-03-24 21:06:15.000000000 +0000
+++ pdfsizeopt/pdfsizeopt.py    2010-03-26 02:37:56.000000000 +0000
@@ -3861,6 +3861,7 @@
   % <streamdict> <decompressed-file>
   systemdict /FontDirectory get {pop undefinefont} forall
   dup /MY exch LoadCff
+  dup type /dicttype eq { pop } if % if LoadCff leaves a dictionary, pop it
   closefile  % is this needed?
   % <streamdict>
   pop

alphabet.pdf
13.9 KB   Download
pdfsizeopt.pat
408 bytes   View   Download
Feb 10, 2011
Project Member #1 pts...@gmail.com
Thanks for the patch. I've integrated it to mainstream. r143 already has it.
Status: Fixed