My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 35: Type1CConverter failed
2 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  pts...@gmail.com
Closed:  Feb 2011


 
Reported by hata.ra...@gmail.com, Apr 8, 2010
(Please add a label starting with Optimize- in ``Labels:'' below, and
remove this paragraph.)

What command do you run to optimize the PDF?

python pdfsizeopt.py --use-pngout=false --use-jbig2=true --use-
multivalent=true 0001.pdf

What does pdfsizeopt display when running the command above?

info: This is pdfsizeopt.py r134.
info: loading PDF from: 0001.pdf
info: loaded PDF of 63832 bytes
info: separated to 51 objs
info: found 3 Type1 fonts loaded
info: writing Type1CConverter (35255 font bytes) to: pso.conv.tmp.ps
info: executing Type1CConverter with Ghostscript: gs -q -dNOPAUSE -dBATCH -
sDEVICE=pdfwrite -dPDFSETTINGS=/printer -dColorConversionStrategy=/
LeaveColorUnchanged -sOutputFile=pso.conv.tmp.pdf -f pso.conv.tmp.ps
Type1CConverter: using interpreter GPL Ghostscript 861 20071121
Error: /undefined in R
Operand stack:
   --nostringval--   --nostringval--   Length   12504   Length1   29   0
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --
nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --
nostringval--   false   1   %stopped_push   1905   1   3   %oparray_pop   
1904   1   3   %oparray_pop   1888   1   3   %oparray_pop   1771   1   3   
%oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --
nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --
nostringval--
Dictionary stack:
   --dict:1145/1684(ro)(G)--   --dict:0/20(G)--   --dict:84/200(L)--
Current allocation mode is local
Last OS error: 2
Current file position is 11459
GPL Ghostscript 8.61: Unrecoverable error, exit code 1
info: Type1CConverter failed, status=0x100
Traceback (most recent call last):
  File "./pdfsizeopt.py", line 6157, in ?
    main(sys.argv)
  File "./pdfsizeopt.py", line 6135, in main
    pdf.ConvertType1FontsToType1C()
  File "./pdfsizeopt.py", line 4026, in ConvertType1FontsToType1C
    type1c_objs = self.GenerateType1CFontsFromType1(
  File "./pdfsizeopt.py", line 3769, in GenerateType1CFontsFromType1
    assert 0, 'Type1CConverter failed (status)'
AssertionError: Type1CConverter failed (status)


What's wrong with the optimized PDF?

Problem with Type1CConverter (I already tried few different versions of 
ghostscript: 8.54; 8.61; 8.63; 8.64; 8.71 and pdfsizeopt.py ends the same 
with all of them) ==> none is created

What should be there in the optimized PDF instead?

0001.pdf
62.3 KB   Download
Apr 13, 2010
#1 william.bader@gmail.com
When pdfsizeopt extracts the fonts in this file, it also pulls out an initialization
for a stream dictionary that uses the pdf R operator to make indirect object
references to find object lengths.  pdfsizeopt should probably either not pull out
that section or else insert the referenced objects.  This is an issue with postscript
generated by pdfsizeopt not with gs, so switching versions of gs will probably not
help.  It looks like the object with the indirect references is not used.  I tried
defining R to do something simple, and it worked.  I have a patch below, and I have
attached my full set of patches.
William Bader
williambader@hotmail.com

--- pdfsizeopt/pdfsizeopt.py-   2010-03-24 21:06:15.000000000 +0000
+++ pdfsizeopt/pdfsizeopt.py    2010-04-13 19:14:33.000000000 +0100

@@ -3417,6 +3423,16 @@
   %      don't redefine `stream'
 } bind def

+% Avoid errors if any extra indirect references are included
+/R where {
+   pop
+}
+{
+  /R { % <objnumber> <gennumber> R <indirectobject> (but just <objnumber> for now)
+    pop
+  } bind def
+} ifelse
+
 % Sort an array, from Ghostscript's prfont.ps.
 /Sort {                        % <array> <lt-proc> Sort <array>
        % Heapsort (algorithm 5.2.3H, Knuth vol. 2, p. 146),

pdfsizeopt.pat
10.0 KB   View   Download
Apr 26, 2010
#2 hata.ra...@gmail.com
Thank you, that`s exactly what I needed
Feb 10, 2011
Project Member #3 pts...@gmail.com
Thank you for the detailed bug report, and thanks to William for the workaround.

I've just fixed the issue in r142. 

Since the PDF spec requires valid values for Length1, Length2 and Length3, for better future compatibility I chose a different way to fix the bug: I made pdfsizeopt resolve indirect refs in Length1, Length2 and Length3.
Status: Fixed

Powered by Google Project Hosting