hefronmedia / pdfsizeopt

Automatically exported from code.google.com/p/pdfsizeopt
0 stars 0 forks source link

Type1CParser fails in gs with /typecheck in --closefile-- [patch] #31

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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

Original issue reported on code.google.com by william.bader@gmail.com on 26 Mar 2010 at 2:59

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the patch. I've integrated it to mainstream. r143 already has it.

Original comment by pts...@gmail.com on 10 Feb 2011 at 9:09