Description

Zend_Pdf_Parser gives an error on line 440: $this->_stringParser->readLexeme();

The parser works fine on my local Windows XP development machine, but it crashes on my Ubuntu 8.04 Linux server. The code is exactly identical on both machines, and so is the PDF file that I am loading with Zend_Pdf::load().

9 /home/mvm_stevens/www_mvm/index.php(11): Bootstrap->runApp()

10 {main}

I outcommented the lines 440 until 453 in Parser.php and echoed the content of $data to the browser, to see if the PDF file is properly read with the 'fread' function, and the output almost identical. The Ubuntu machine seems to recognize more characters. For example, the Windows version showed the following as the 2nd line:
%����
and Ubuntu showed:
%âãÏÓ

Anybody any ideas what is going on or what I can do to get the Ubuntu server load these PDF files?

Comments

Posted by Kai Bielenberg (kaib) on 2010-01-15T02:52:38.000+0000

I had the same issue. The problem in my case was that i configure mbstring.func_overload to use mbstring functions instead of the normal string functions. Try something like this to see if this is also your problem:

I've encountered the same problem on one domain hosting based on linux. I tried zf 1.5.1 and some versions between 1.5.1 and 10.1 but nothing helped. Zf 1.5.1 displayed another problem than "'startxref' keyword expected" (I haven't written it down) but it also failed.

After some investigation I discovered that code at line 440 $this->_stringParser->readLexeme() is actually expected to read 'startxhref' word from pdf file. But in fact it reads 'startxhre' (without 'f' at the end) so exception is thrown.

On my Windows machine running Zend 1.9.6 and Php 5.2.8 it all worked fine. We then rolled it out to our live systems where it only works on one of the two Ubuntu machines.

I was tasked with figuring out what is happening here. We found that our one system is runnin PHP 5.2.4 and the other is running 5.2.5 both with Zend 1.9.6.

The one running 5.2.5 is working fine but the one with 5.2.4 is giving us the problems.

I then had a look at the StringParser.php. In there you will find that Zend 1.9.6 checks for \f as one of the white space characters. This is not supported in version 5.2.4 yet (http://php.net/ChangeLog-5.php). So I had to go do a version check and adjust the data parser.

You want to go to line 267 and replace it with the following block of code:

Could this be fixed and backported to 1.9.7 (1.9.8 perhaps?) as the minimum requirement for ZF is PHP 5.2.4 and not PHP 5.2.5.

Posted by Christiaan Kras (htbaa) on 2010-05-02T23:45:01.000+0000

This is a serious showstopper. Could this PLEASE be fixed ASAP so we don't have to patch StringParser.php ourselves? This fix is here, please apply it.

Posted by Christiaan Kras (htbaa) on 2010-05-02T23:53:50.000+0000

This patch applies to Zend_Pdf_StringParser of ZendFramework 1.10.4

Posted by Christiaan Kras (htbaa) on 2010-05-25T04:11:38.000+0000

I'm sorry for spamming this issue, but could this fix be applied before the next mini-release?

Posted by Pádraic Brady (padraic) on 2010-05-27T06:11:08.000+0000

Sorry for the delay guys, I'm not a Zend_Pdf maintainer but I noticed your Devzone comment ;). Ask, and thou shalt receive! So I reviewed the patch. Fix looks good so I've applied it in r22311. Worth noting, there are always devs around on our regular bug hunt days - if there are other patches anyone needs applying you can grab us on IRC at those times for assistance.