hefronmedia / pdfsizeopt

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

__main__.PdfTokenParseError: unexpected stream in: 4 0 obj #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
windows xp sp3+python2.5

python.exe pdfsizeopt.py --use-pngout=true
--use-jbig2=true --use-multivalent=true linux.pdf
info: This is pdfsizeopt.py rUNKNOWN.
info: loading PDF from: linux.pdf
info: loaded PDF of 31667 bytes
warning: problem with xref table, finding objs anyway: xref subsection
syntax er
ror
info: separated to 8 objs
info: found 0 Type1 fonts loaded
info: found 0 Type1C fonts loaded
Traceback (most recent call last):
  File "pdfsizeopt.py", line 6027, in <module>
    main(sys.argv)
  File "pdfsizeopt.py", line 6016, in main
    pdf.OptimizeImages(use_pngout=use_pngout, use_jbig2=use_jbig2)
  File "pdfsizeopt.py", line 4768, in OptimizeImages
    obj.Get(name), objs=self.objs)
  File "pdfsizeopt.py", line 2062, in ResolveReferences
    data = cls.PDF_REF_RE.sub(Replacement, data)
  File "pdfsizeopt.py", line 2048, in Replacement
    'unexpected stream in: %d 0 obj' % obj_num)
__main__.PdfTokenParseError: unexpected stream in: 4 0 obj

Original issue reported on code.google.com by roc...@gmail.com on 28 Oct 2009 at 11:34

Attachments:

GoogleCodeExporter commented 9 years ago
the same error under linux
the version of pdfsizeopt.py is r95

the pdf is create by pdf.py(part of agl's jbig2enc

Original comment by roc...@gmail.com on 28 Oct 2009 at 11:38

GoogleCodeExporter commented 9 years ago
Fixed in r100, please svn update.

By the way, if you want to create a PDF which takes advantage of JBIG2 image
compression, I'd recommend creating a normal PDF anyhow (e.g. with sam2p), and
optimizing it with pdfsizeopt.py. pdfsizeopt.py autodetects that JBIG2 can be
applied, tries it, and if it saves space, it recompresses the image using JBIG2.

Original comment by pts...@gmail.com on 31 Oct 2009 at 9:48

GoogleCodeExporter commented 9 years ago
not I want to convert JBIG2 to PDF, just want to test your application, btw, I 
have
no need of pdfsizeopt at all, just find pdfsizeopt is a good solution, and have
interesting in it.
It is my hobby to study PDF, I am a .net developer, and manage a java team, and 
our
company focus on email marketing. all I need to do at office has no business 
with
PDF, but I like PDF.

Original comment by roc...@gmail.com on 31 Oct 2009 at 4:55

GoogleCodeExporter commented 9 years ago
got new problem now

F:\2009\pdfsizeopt\win32>c:\Python25\python.exe pdfsizeopt.py --use-pngout=true
--use-jbig2=true --use-multivalent=true linux.pdf
info: This is pdfsizeopt.py rUNKNOWN.
info: loading PDF from: linux.pdf
info: loaded PDF of 31667 bytes
warning: problem with xref table, finding objs anyway: xref subsection syntax er
ror
info: separated to 8 objs
info: found 0 Type1 fonts loaded
info: found 0 Type1C fonts loaded
info: writing Multivalent input PDF: pso.conv.mi.tmp.pdf
info: saving PDF with 8 objs to: pso.conv.mi.tmp.pdf
info: generated 31612 bytes (100%)
info: executing Multivalent to optimize PDF: java -cp Multivalent.jar tool.pdf.C
ompress pso.conv.mi.tmp.pdf
file:/F:/2009/pdfsizeopt/win32/pso.conv.mi.tmp.pdf, 31612 bytes
additional compression may be possible with:
         -compact
=> new length = 31461, saved 0%, elapsed time = 0 sec
info: Multivalent generated pso.conv.mi.tmp-o.pdf of 282 bytes (1%)
Traceback (most recent call last):
  File "pdfsizeopt.py", line 6121, in <module>
    main(sys.argv)
  File "pdfsizeopt.py", line 6114, in main
    pdf.SaveWithMultivalent(output_file_name)
  File "pdfsizeopt.py", line 5948, in SaveWithMultivalent
    data = self.FixPdfFromMultivalent(data)
  File "pdfsizeopt.py", line 5722, in FixPdfFromMultivalent
    obj_num_by_ofs_out=obj_num_by_in_ofs)
  File "pdfsizeopt.py", line 5475, in ParseSequentially
    objs=length_objs)
  File "pdfsizeopt.py", line 450, in __init__
    (endstream_str, file_ofs + stream_end_idx))
__main__.PdfTokenParseError: expected endstream+endobj in '' at 10188

Original comment by roc...@gmail.com on 31 Oct 2009 at 5:19

Attachments: