1

I have downloaded the updated version of mpdf and using it with php. It is giving me the following error.

"fatal error: Trait 'Mpdf\Strict' not found in E:\xampp\htdocs\PDF\mpdf\Mpdf.php on line 39".

$html = '<h2>mpdf test.</h2>';

include("mpdf/mpdf.php");

$mpdf = new mPDF('c','A4','','',32,25,27,25,16,13); 

$mpdf->SetDisplayMode('fullpage');

$mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first 
 level of a list

// LOAD a stylesheet
$stylesheet = file_get_contents('mpdfstyletables.css');
$mpdf->WriteHTML($stylesheet,1);    // The parameter 1 tells that this is css/style only and no body/html/text

$mpdf->WriteHTML($html,2);

$mpdf->Output('mpdf.pdf','I');
exit;
2
  • is this file present in location? also change include to require_once May 13, 2019 at 10:21
  • Yes the file is present May 14, 2019 at 4:36

2 Answers 2

6

You are directly including mpdf via

include("mpdf/mpdf.php");

which will only include the core file but not any other file mPDF may need in the generation process. The correct way would be to use:

// Require composer autoload
require_once __DIR__ . '/vendor/autoload.php';
// Create an instance of the class:
$mpdf = new \Mpdf\Mpdf(); 

This will make sure that required classes will be autoloaded as soon as they are referenced.

For more info, check the "Getting started" chapter on the mPDF web page.

0

if ($this->bodyBackgroundColor{0} == 5) { // RGBa Severity: Compile Error

Message: Array and string offset access syntax with curly braces is no longer supported

Filename: src/Mpdf.php

Line Number: 2238

Backtrace:

1
  • 1
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center. Jul 16 at 17:55

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.