skip to Main Content

I am using mpdf 8.1 with yii2 and php version is 5.6.40 for pdf report download. It’s works fine in local environment. But class mpdf is not found in live server with same php version.

mpdf library is uploaded in vendor directory and path is vendor/mpdf/mpdf. And I’m using like these,

use MpdfMpdf;
class ReportController extends Controller
{
    public function actionPdfUsageReport()
    {
          $content = "<div>Hello</div>";
          $marginValue = PdfSettings::GetTabularReportMarginSetting();
          $pdf = new Mpdf($marginValue);
          $stylesheet = file_get_contents(Yii::getAlias('@webroot') . "/css/mpdfstyletables.css");
          $pdf->WriteHTML($stylesheet, 1);
          $pdf->SetProtection(array('print'));
          $pdf->SetTitle("Title");
          $pdf->SetAuthor("Author.");
          $pdf->SetDisplayMode('fullpage');
          $pdf->WriteHTML($content);
          return $pdf->Output('Usage Summary.pdf', 'I');
    }
}

System information
Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips PHP/5.6.40

2

Answers


  1. Chosen as BEST ANSWER

    mpdf library was uploaded manually, so I clean that and reinstalled mpdf library through composer. works fine now. Thanks to @MuhammadOmerAslam


  2. In my case, it has happened that I ran the command "composer require mpdf/mpdf" in the wrong directory. It’s happened before. Checking what I did showed me the error. I made sure to run it again in the Cake directory and then the error disappeared.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search