Reputation: 81
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 Mpdf\Mpdf;
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
Upvotes: 3
Views: 6987
Reputation: 36
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.
Upvotes: 0
Reputation: 81
mpdf library was uploaded manually, so I clean that and reinstalled mpdf library through composer. works fine now. Thanks to @MuhammadOmerAslam
Upvotes: 2