I am trying to create a .pdf file using mPDF in a Zend Framework application from the output of an action.
Here is the code for my action:
public function testAction()
{
$this->_helper->viewRenderer->setNoRender();
$this->_helper->layout->disableLayout();
$this->view->foo = 'bar';
$this->render();
$output = $this->getResponse()->getBody();
$layout = new Zend_Layout();
$layout->content = $output;
$layout->setLayoutPath(dirname(dirname(__FILE__)) . '/views/layouts/');
$layout->setViewSuffix('tpl');
$layout->setLayout('pdf');
$html = $layout->render();
$mpdf = new mPDF('utf-8', 'A4');
$mpdf->WriteHTML($html);
$mpdf->Output('report.pdf', 'D');
}
If the displayed content is long (i.e., a few paragraphs) when loading a .pdf file, Adobe Reader raises the following error: Adobe Reader could not open the report.pdf file because it is either an unsupported file or because the file was damaged ( for example, it was sent as an email attachment and was incorrectly decoded).
, mpdf , Zend, .pdf - . , Adobe Reader , (.. , ).
- , ?