ourtown1 / pdfsizeopt

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

Type1CConverter failed #35

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
(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?

Original issue reported on code.google.com by hata.ra...@gmail.com on 8 Apr 2010 at 10:58

Attachments:

GoogleCodeExporter commented 8 years ago
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),

Original comment by william.bader@gmail.com on 13 Apr 2010 at 8:08

Attachments:

GoogleCodeExporter commented 8 years ago
Thank you, that`s exactly what I needed

Original comment by hata.ra...@gmail.com on 26 Apr 2010 at 2:50

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

Original comment by pts...@gmail.com on 10 Feb 2011 at 7:45