zackw / pdfsizeopt

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

Traceback when computing stats for a PDF file that uses tikz/pgf #74

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When trying to use pdfsizeopt (from trunk, revision 221) to show stats of a PDF 
file that contains a drawing in tikz/pgf, I get the following traceback:

pdfsizeopt --stats entrada-algoritmo-saida.pdf 
info: This is pdfsizeopt rUNKNOWN size=316358.
info: computing statistics for PDF: entrada-algoritmo-saida.pdf
info: PDF size is 10613 bytes
Traceback (most recent call last):
  File "/usr/bin/pdfsizeopt", line 7841, in <module>
    main(sys.argv)
  File "/usr/bin/pdfsizeopt", line 7757, in main
    PdfData.ComputePdfStatistics(file_name=args[0])
  File "/usr/bin/pdfsizeopt", line 6890, in ComputePdfStatistics
    setitem_callback=SetItemCallback)
  File "/usr/bin/pdfsizeopt", line 6745, in ParseSequentially
    setitem_callback(obj_num, pdf_obj, i)  # self.objs[obj_num] = pdf_obj
  File "/usr/bin/pdfsizeopt", line 6848, in SetItemCallback
    for head in PdfObj.ParseArray('[%s]' % obj_data):
  File "/usr/bin/pdfsizeopt", line 1204, in ParseArray
    return cls._ParseTokens(data, start, end, end)
  File "/usr/bin/pdfsizeopt", line 1344, in _ParseTokens
    (match.start(1), value1[0 : 16], exc))
__main__.PdfTokenParseError: bad array at 98, got '<< /pgf@CA.5 << '...: 
invalid name '.5' with stack ['-', '<', '<']

I will attach both the source and the PDF that caused the problem to this issue.

I am using a Debian unstable system (but I don't really think that this would 
matter give the above). If you need further information, please let me know.

Original issue reported on code.google.com by rbr...@gmail.com on 16 Feb 2013 at 1:59

Attachments:

GoogleCodeExporter commented 8 years ago
Fixed in r222 based on the information you've provided. If it still doesn't 
work, please let me know.

Thank you for reporting this bug, and thank you for providing details about 
what was going wrong. Based on the information you have provided it was very 
easy for me to reproduce and diagnose the problem.

Indeed, pdfsizeopt was buggy, beacuse it could parse the PDF numeric token 
`.5'. I've fixed it by modifying the regexp for numeric tokens.

Original comment by pts...@gmail.com on 17 Feb 2013 at 10:14