这个程序正在用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';
...发布于 2014-08-13 21:04:22
另一种附加相同文件的方法解决了这个问题:
$file = Zend_Registry::get('config')->app->pdf_path."Foundation Year Students-Instructions.pdf"; //load pdf from string
$content = file_get_contents($file); // e.g. ("attachment/abc.pdf")
$attachment = new Zend_Mime_Part($content);
$attachment->type = 'application/pdf';
$attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
$attachment->encoding = Zend_Mime::ENCODING_BASE64;
$attachment->filename = 'Foundation Year Students-Instructions.pdf'; // name of file
$mail->addAttachment($attachment); https://stackoverflow.com/questions/25294246
复制相似问题