【发布时间】:2014-08-13 19:09:30
【问题描述】:
程序正在使用 Zend_Pdf 创建 PDF 附件并加载 pdf 文件。我知道 Zend_Pdf 只能处理等于或低于 1.4 版本的 PDF 文件。
所有文件均为 1.3 版本。五个 pdf 附件已正确创建和附加,但一个文件在加载时产生错误。我不确定是什么原因以及如何解决它:
错误 1:文件降级到 1.3 版本时
An error occurred
Application error
Exception information:
Message: Outline childs load error.
Stack trace:
#0 C:\WebSites\Web_Applications\workstudy\library\Zend\Pdf\Outline\Loaded.php(345): Zend_Pdf_Outline_Loaded->__construct(Object(Zend_Pdf_Element_Reference), Object(SplObjectStorage))
#1 C:\WebSites\Web_Applications\workstudy\library\Zend\Pdf\Outline\Loaded.php(345): Zend_Pdf_Outline_Loaded->__construct(Object(Zend_Pdf_Element_Reference), Object(SplObjectStorage))
#2 C:\WebSites\Web_Applications\workstudy\library\Zend\Pdf\Outline\Loaded.php(345): Zend_Pdf_Outline_Loaded->__construct(Object(Zend_Pdf_Element_Reference), Object(SplObjectStorage))
#3 C:\WebSites\Web_Applications\workstudy\library\Zend\Pdf\Outline\Loaded.php(345): Zend_Pdf_Outline_Loaded->__construct(Object(Zend_Pdf_Element_Reference), Object(SplObjectStorage))
#4 C:\WebSites\Web_Applications\workstudy\library\Zend\Pdf\Outline\Loaded.php(345): Zend_Pdf_Outline_Loaded->__construct(Object(Zend_Pdf_Element_Reference), Object(SplObjectStorage))
#5 C:\WebSites\Web_Applications\workstudy\library\Zend\Pdf\Outline\Loaded.php(345): Zend_Pdf_Outline_Loaded->__construct(Object(Zend_Pdf_Element_Reference), Object(SplObjectStorage))
#6 C:\WebSites\Web_Applications\workstudy\library\Zend\Pdf\Outline\Loaded.php(345): Zend_Pdf_Outline_Loaded->__construct(Object(Zend_Pdf_Element_Reference), Object(SplObjectStorage))
#7 C:\WebSites\Web_Applications\workstudy\library\Zend\Pdf\Outline\Loaded.php(345): Zend_Pdf_Outline_Loaded->__construct(Object(Zend_Pdf_Element_Reference), Object(SplObjectStorage))
#8 C:\WebSites\Web_Applications\workstudy\library\Zend\Pdf.php(549): Zend_Pdf_Outline_Loaded->__construct(Object(Zend_Pdf_Element_Reference))
#9 C:\WebSites\Web_Applications\workstudy\library\Zend\Pdf.php(317): Zend_Pdf->_loadOutlines(Object(Zend_Pdf_Element_Reference))
#10 C:\WebSites\Web_Applications\workstudy\library\Zend\Pdf.php(253): Zend_Pdf->__construct('C:\WebSites\Web...', NULL, true)
#11 C:\WebSites\Web_Applications\workstudy\application\modules\default\models\Students.php(609): Zend_Pdf::load('C:\WebSites\Web...')
#12 C:\WebSites\Web_Applications\workstudy\application\modules\default\controllers\StudentsController.php(262): Model_Students->generateDocuments()
#13 C:\WebSites\Web_Applications\workstudy\library\Zend\Controller\Action.php(513): StudentsController->quizCompletedAction()
#14 C:\WebSites\Web_Applications\workstudy\library\Zend\Controller\Dispatcher\Standard.php(289): Zend_Controller_Action->dispatch('quizCompletedAc...')
#15 C:\WebSites\Web_Applications\workstudy\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#16 C:\WebSites\Web_Applications\workstudy\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#17 C:\WebSites\Web_Applications\workstudy\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#18 C:\WebSites\RSS\Workstudy\index.php(26): Zend_Application->run()
**错误2:文件未正确降级到较低版本时可能会发生这种情况**
An error occurred
Application error
Exception information:
Message: Incorrect reference to the object
Stack trace:
#0 C:\WebSites\Web_Applications\workstudy\library\Zend\Pdf\Element\Reference.php(128): Zend_Pdf_Element_Reference->_dereference()
#1 C:\WebSites\Web_Applications\workstudy\library\Zend\Pdf.php(529): Zend_Pdf_Element_Reference->getType()
#2 C:\WebSites\Web_Applications\workstudy\library\Zend\Pdf.php(317): Zend_Pdf->_loadOutlines(Object(Zend_Pdf_Element_Reference))
#3 C:\WebSites\Web_Applications\workstudy\library\Zend\Pdf.php(253): Zend_Pdf->__construct('C:\WebSites\Web...', NULL, true)
#4 C:\WebSites\Web_Applications\workstudy\application\modules\default\models\Students.php(597): Zend_Pdf::load('C:\WebSites\Web...')
#5 C:\WebSites\Web_Applications\workstudy\application\modules\default\controllers\StudentsController.php(262): Model_Students->generateDocuments()
#6 C:\WebSites\Web_Applications\workstudy\library\Zend\Controller\Action.php(513): StudentsController->quizCompletedAction()
#7 C:\WebSites\Web_Applications\workstudy\library\Zend\Controller\Dispatcher\Standard.php(289): Zend_Controller_Action->dispatch('quizCompletedAc...')
#8 C:\WebSites\Web_Applications\workstudy\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#9 C:\WebSites\Web_Applications\workstudy\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#10 C:\WebSites\Web_Applications\workstudy\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#11 C:\WebSites\RSS\Workstudy\index.php(26): Zend_Application->run()
#12 {main}
PHP代码:
...
$mail = new Zend_Mail();
$mail->setFrom(Zend_Registry::get('config')->app->contact->email);
$mail->addTo($this->getUscEmail(), $this->getFirstName().' '.$this->getLastName());
$mail->addCc(Zend_Registry::get('config')->app->contact->email, 'SOWK FWS');
$mail->setSubject('Workstudy Documentation - '.$this->getFirstName().' '.$this->getLastName());
$content = '......text......';
$mail->setBodyText(strip_tags($content));
$mail->setBodyHtml($content);
...
$file = Zend_Registry::get('config')->app->pdf_path."Foundation Year Students.pdf"; //load pdf from string
$pdf = Zend_Pdf::load($file);
$at1 = $mail->createAttachment($pdf->render());
$at1->filename = "Foundation Year Students steve.pdf";
$at1->type = 'application/pdf';
...
【问题讨论】:
标签: php pdf zend-framework zend-framework2 zend-pdf