robregonm / yii2-pdf

PDF Reports from HTML Views (Html to PDF formatter) for Yii 2.0
BSD 3-Clause "New" or "Revised" License
46 stars 36 forks source link

yii2-pdf is not compatible with mpdf v7+ #28

Open zoran-grujic opened 5 years ago

zoran-grujic commented 5 years ago

I wanted to use PHP 7+ and I stumbled into a problem. It is required to use mpdf v7 with PHP 7+ and yii2-pdf does not support mpdf v7+. Is there will to update the yii2-pdf? It seems like the change is rather trivial according to: https://harrybailey.com/2018/08/yii-1-php-7-1-yii-pdf-and-mpdf/

zoran-grujic commented 5 years ago

Just to confirm, I managed to make it work with mpdf v7.1.9. It was required to change single line in PdfResponseFormatter.php:

protected function formatPdf($response) { $mpdf = new \Mpdf\Mpdf([$this->mode, $this->format, $this->defaultFontSize, $this->defaultFont, $this->marginLeft, $this->marginRight, $this->marginTop, $this->marginBottom, $this->marginHeader, $this->marginFooter, $this->orientation ]);

NOTE: class name: \Mpdf\Mpdf constructor accepts array: [$this->mode, $this->format, ... ], there are '[' and ']' around parameter list.