Bina Pithadiya
Bina Pithadiya

Reputation: 23

dompdf not work in zend framework 2

I get this error, when using Zend Framework v2.4: Call to undefined method Zend\Mvc\View\Http\ViewManager::getResolver() in /../../../demo/vendor/dino/dompdf-module/src/DOMPDFModule/Mvc/Service/ViewPdfRendererFactory.php on line 39 But there is no getResolver method in viewmanager. I am using zend framework 2.4/

Can you help me to solve this?

This is included in vender.

<?php

use DOMPDFModule\View\Model\PdfModel;

This is controller action

public function generatepdfAction(){
    //  $pdf1 = new Zendpdf\PdfDocument();
    echo "bbb";
    $pdf = new PdfModel();
        $pdf->setOption('filename', 'monthly-report'); // Triggers PDF download, automatically appends ".pdf"
        $pdf->setOption('paperSize', 'a4'); // Defaults to "8x11"
        $pdf->setOption('paperOrientation', 'landscape'); // Defaults to "portrait"

        // To set view variables
        $pdf->setVariables(array(
          'message' => 'Hello'
        ));

        return $pdf;
    }

Upvotes: 2

Views: 1055

Answers (1)

av3
av3

Reputation: 86

It's not a error in your code. This is a known issue as you can see on https://github.com/raykolbe/DOMPDFModule/issues/37

There is also a pull request for that issue. I solved this with creating my own DOMPDFModule with the changes of this commit, because it seems that there won't be an update of DOMPDFModule soon.

Another possibility would be using an older version of zend-mvc, because the issue appears since zend-mvc 2.7. Just use

"zendframework/zend-mvc": "~2.6.3"

in your composer.json and the the DOMPDFModule will work again. But this should be only a temporarily solution if you want to use new features of the Zend Framework and its modules in the future.

Upvotes: 4

Related Questions