1. "Fabrik 4" helpers needed!

    You are invited to join other community members active in coding, maintaining and improving Fabrik. Please visit https://fabrik.help for more information!
    Dismiss Notice

Updating mpdf lib for PHP 8.1

Discussion in 'Community' started by lcollong, Dec 2, 2022.

  1. lcollong

    lcollong FabriKant d'applications web

    Level: Community
    Hi there,

    Is anyone has already successfully updated a site using mPDF lib to PHP 8 ?
    I'm stick with this error : Fatal error: Trait "setasign\Fpdi\FpdiTrait" not found
    I've downloaded the latest version from there : https://github.com/mpdf/mpdf unzip it and uploaded the files in the right directory (/libraries/fabrik/vendor/mpdf/mpdf).
    The Fabrik files themselves have been updated from github on november the 12th
    Joomla version : 3.10.11
    PHP version : 8.1.0

    Thanks for any advice
  2. troester

    troester Well-Known Member Staff Member

    Level: Community
    Did you try to take it from Fabrik4? I did not test. But in Fabrik4 mPDF is working.
  3. lcollong

    lcollong FabriKant d'applications web

    Level: Community
    I've just tried but I get the same result.
    I've renamed original mpdf folder to mpdf_original and copied the whole content of the mpdf directory from a J4 site to my test site on /libraries/fabrik/vendor/mpdf/ .

    My original test was from a php cron script.
    So I set pdf icon on a usual frontend list rendering (working on the production site under PHP 7.4) and I get the same error (pure Fabrik's code) :
    Fatal error: Trait "setasign\Fpdi\FpdiTrait" not found in /home/bishlws/examulmtest/libraries/fabrik/vendor/mpdf/mpdf/src/FpdiTrait.php on line 25

    I've also copied the domPDF directory from J4 to my J3 test site and I get :

    Class "Masterminds\HTML5" not found /zzzz/xxxx/yyyyyy/libraries/fabrik/vendor/dompdf/dompdf/src/Dompdf.php:477

    Call stack
    Function Location
    1 () JROOT/libraries/fabrik/vendor/dompdf/dompdf/src/Dompdf.php:477
    2 Dompdf\Dompdf->loadHtml() JROOT/libraries/fabrik/vendor/dompdf/dompdf/src/Dompdf.php:394
    3 Dompdf\Dompdf->load_html() JROOT/libraries/src/Document/PdfDocument.php:276
    4 Joomla\CMS\Document\PdfDocument->render() JROOT/libraries/src/Application/CMSApplication.php:1112
    5 Joomla\CMS\Application\CMSApplication->render() JROOT/libraries/src/Application/SiteApplication.php:778
    6 Joomla\CMS\Application\SiteApplication->render() JROOT/libraries/src/Application/CMSApplication.php:231
    7 Joomla\CMS\Application\CMSApplication->execute() JROOT/index.php:49
  4. lcollong

    lcollong FabriKant d'applications web

    Level: Community
  5. lcollong

    lcollong FabriKant d'applications web

    Level: Community
    So I finally let it work.
    Here is my setup :

    replace the mpdf files in /libraries/fabrik/vendor/mpdf/ with the ones used for Fabrik 4 (last version of mpdf ?)
    replace the fpdi files in /libraries/fabrik/vendor/setasign/ with the ones used for Fabrik 4 (the ones found here : https://github.com/Setasign/FPDI ?)

    I did not find the right place to make the fpdi classes loaded by fabrik. So I've edited the file : /libraries/fabrik/vendor/mpdf/mpdf/src/FpdiTrait.php to add the " fpdi autoload" :

    Code (Text):

    namespace Mpdf;

    include_once JPATH_LIBRARIES . '/fabrik/vendor/setasign/fpdi/src/autoload.php';   // added line !

    use setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException;
    use setasign\Fpdi\PdfParser\Filter\AsciiHex;
    And it works....

Share This Page