Details
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().
The error stack is below:
Error: Pdf file syntax error. 'startxref' keyword expected. Offset - 0x2180.
#0 /home/mvm_stevens/www_mvm/library/Zend/Pdf.php(303): Zend_Pdf_Parser->__construct('/home/mvm_steve...', Object(Zend_Pdf_ElementFactory_Proxy), true)
#1 /home/mvm_stevens/www_mvm/library/Zend/Pdf.php(253): Zend_Pdf->__construct('/home/mvm_steve...', NULL, true)
#2 /home/mvm_stevens/www_mvm/application/models/Report/Pdf.php(15): Zend_Pdf::load('/home/mvm_steve...')
#3 /home/mvm_stevens/www_mvm/application/controllers/ReportsController.php(102): Report_Pdf->loadTemplate('10_slf_mon1_tem...')
#4 /home/mvm_stevens/www_mvm/application/controllers/ReportsController.php(38): ReportsController->createReport(Array)
#5 /home/mvm_stevens/www_mvm/library/Zend/Controller/Action.php(513): ReportsController->initialrepAction()
#6 /home/mvm_stevens/www_mvm/library/Zend/Controller/Dispatcher/Standard.php(289): Zend_Controller_Action->dispatch('initialrepActio...')
#7 /home/mvm_stevens/www_mvm/library/Zend/Controller/Front.php(946): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#8 /home/mvm_stevens/www_mvm/application/bootstrap.php(56): Zend_Controller_Front->dispatch()
#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?
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:
ini_set('mbstring.internal_encoding', 'ASCII');
$pdf = Zend_Pdf::load('my.pdf');
ini_set('mbstring.internal_encoding', 'UTF-8');