Adobe Reader cannot open .pdf file created using mPDF in Zend Framework

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 , (.. , ).

- , ?

+3
2

, ,

0

Adobe Reader , PDF, PDF . PDF- , - : % PDF-1.4 % A ¢ Ã £ AA "

PHP .

: mpdf forum IanBack

0

Source: https://habr.com/ru/post/1627838/


All Articles