0

I'm converting a Joomla 3 component to make it compatible with Joomla 4. I'm having an issue when trying to use fpdf. In joomla 3, the fpdf file was included like this at the top of the model : include('./components/com_mycomp/libraries/fpdf/morepagestable.php');

Then the pdf class was called this way in a function : $pdf=new PDF('P','mm','A4');

I did the same in Joomla 4 but got the following error : Class 'Mycomp\Component\Mycomp\Administrator\Model\PDF' not found

Still haven't found the correct way to include the class

Thanks in advance for your help

Ossepove
  • 27
  • 2

1 Answers1

0

This is a problem with PHP namespaces. Joomla is encourage the use of namespaces in J4 a lot more. The context where you are calling the PDF constructor is within namespace 'Mycomp\Component\Mycomp\Administrator\Model', FPDF doesn't use namespaces though. So add a backslash to your constructor call and it should work again:

 $pdf=new \PDF('P','mm','A4');
Dave
  • 1
  • 1