Extension talk:Mpdf

About this board

MPDF is not giving image with wiki 1.35

Apatha11 (talkcontribs)

HI Support Desk,

Following are the installed software product version(s) those are being used in our RHEL7 server environment.

Installed software

Product Version
MediaWiki 1.35.1
PHP 7.4.15 (apache2handler)

I have tried MPDF and its downgliding pdf but not giving image, can you please suggest where we can enable for image?

Yes I have set it up properly as given in MPDF documentation. (Extension:Mpdf)

The path is not coming full in HTML. (/wiki135/images/5/57/enterprise-wiki.jpg).

From where I can change it, or it should be pick this automatically. Path should be like  :

https://localhost/wiki135/images/5/57/enterprise-wiki.jpg not /wiki135/images/5/57/enterprise-wiki.jpg

Error: Error parsing image file - image type not recognised, and not supported by GD imagecreate

Steps I have done:

  1. wget https://extdist.wmflabs.org/dist/extensions/Mpdf-REL1_35-94bd27c.tar.gz

2. tar -xzf Mpdf-REL1_35-94bd27c.tar.gz -C /data/www/html/wiki135/extensions

3. cd data/www/html/wiki135

#php maintenance/update.php

4. added("extensions/Mpdf/composer.json") in wiki135/composer.local.json-sample


"extra": {

"merge-plugin": {

"include": [

"extensions/Mpdf/composer.json"] } } }

5. in mpdf dir

#composer update --no-dev

6.added in LocalSettings.php

require_once( "$IP/extensions/Mpdf/vendor/autoload.php");

wfLoadExtension( 'Mpdf' );


7.Given 777 to all 3 dir (/data/www/html/wiki135/extensions/Mpdf/vendor/mpdf/mpdf)





Please help me to fix this.


Apatha11 (talkcontribs)

Waiting for response.

AKlapper (WMF) (talkcontribs)
Apatha11 (talkcontribs)

Could you please let me know that which steps are pending. Please suggest if you know.. I have done all steps which is mentioned in the mpdf document.

In mpdf document they asked to add in composer.local.json-sample and add require_once in localsettings.Php. I did what mentioned in given mpdf doc.


AKlapper (WMF) (talkcontribs)

You state "In mpdf document they asked to add in composer.local.json-sample": No. That is not true. The page that you linked really does not say that.

Apatha11 (talkcontribs)

Thanks for your time !! Please check the doc, it’s mentioned there , Could you please help me to fix this rather than discus about above thing. . Please Suggest how can I fix this or correct me where I have done wrong .

Apatha11 (talkcontribs)
Please check here
AKlapper (WMF) (talkcontribs)

As your screenshot clearly shows, "composer.local.json-sample" it is NOT mentioned there, which I have now written three times. This conversation is not a good use of my time as you unfortunately do not seem to carefaully read and follow the docs, so you run into issues.

Apatha11 (talkcontribs)

HI Please Try to understand, They are using composer.local.json on the root as well we have composer.local.json-sample file on the root, our file name is not same in root of wiki.

You want me to rename composer.local.json-sample to composer.local.json? then It will work according to you? or I can include this line in composer.json ("extensions/Mpdf/composer.json")

Kindly clear this.

One more thing, please have look at the below info regarding our application.

We are using LDAP+SSO login in our application Can you confirm that is MPDF compatible with these Protocol services.

With LDAP+SSO it's not working and it's throwing us an unauthorized error in the image function. ( function _imageTypeFromString(&$data) )

$data is printing unauthorized error.

We have set 777 permission to the image folder.

The same code is working fine where we are not using LDAP+SSO. Can you confirm that MPDF works with the server which is secured with a password?

Reply to "MPDF is not giving image with wiki 1.35"

When exporting a page, no images are inserted

Alechandrop (talkcontribs)

On pages that contain Math formulas, an error is displayed when exporting to PDF

Apatha11 (talkcontribs)

HI , Did you solve this issue? I am also facing same issue.

Reply to "When exporting a page, no images are inserted"

Mpdf/MpdfAction.php: Class 'mPDF' not found

6 (talkcontribs)

Error from line 97 of /var/www/wiki/extensions/Mpdf/MpdfAction.php: Class 'mPDF' not found

Fixed by inserting this line at the begin of the file:

require_once 'mpdf/mpdf.php';

Yaron Koren (talkcontribs)

How did you install the mPDF library?

Bjsdaiyu (talkcontribs)

I've had this same issue on a new install for MW 1.35. I followed the 1) download main Mpdf code -> `$IP/extensions/Mpdf` 2) download the mpdf source -> `$IP/extensions/Mpdf/mpdf` 3) enable the Mpdf extension in LocalSettings install path. Adding the line OP suggested to MpdfAction.php fixed it for me as well.

Seb35 (talkcontribs)

When you download from Extension Distributor it should work out-of-the-box, but when you download it from Git (or Github → Download ZIP) you have to execute Composer inside the directory Mpdf.

2001:14BA:2BF5:C300:4591:4354:337A:6ED5 (talkcontribs)


I can't get working from Github Mpdf REL1_36 and mpdf 8.0.10 in my MediaWiki 1.35.2 and PHP 7.4.16.

And when I use Extension Distributor, it can download a new Mpdf-version but mpdf is old. And old mpdf does not work with PHP 7.4. So how to get latest stable Mpdf + mPDF v8.0.10 package?

What do you mean "execute Composer inside the directory Mpdf"?


2001:14BA:2BF5:C300:988B:8262:6E5E:2327 (talkcontribs)

Update to previous message.

I downloaded mediawiki-extensions-Mpdf REL1_36 from Github, extracted it to an empty /extensions/Mpdf -directory, executed 'composer require mpdf/mpdf' inside the directory. Still, /extensions/Mpdf/MpdfAction.php: Class 'mPDF' not found

Any idea?

Reply to "Mpdf/MpdfAction.php: Class 'mPDF' not found"

mpdf cannot be installed via composer on MW 1.35.2

S0ring (talkcontribs)

MW 1.35.2 runs with php 7.3.27 but mpdf v6.1.4 requires max. php 7.0.*, therefore the installation fails

# composer install --no-dev

Loading composer repositories with package information

Installing dependencies from lock file

Your requirements could not be resolved to an installable set of packages.

  Problem 1

   - mpdf/mpdf v6.1.4 requires php ^5.4.0 || 7.0.* -> your PHP version (7.3.27) does not satisfy that requirement.

Reply to "mpdf cannot be installed via composer on MW 1.35.2"

Internal error - PDF Export is not possible

Weonde (talkcontribs)

I installed the extension and I can check up my Specialpage Version, the version is correctly installed. 

I just took your generic example code - and the extension isn´t working.

An internal error and fatal exception is my personal result. Can you help me with this problem?

Weonde (talkcontribs)
Nicopel (talkcontribs)


I got the exact same error here and wanna know if any solution has been found.

Thanks by advance for your consideration @Pastakhov.

Erreur interne

[52816119159d63c1bb2495da] 2021-01-11 14:15:52: Erreur fatale de type « Error »

Récupérée de « myLink »

Reply to "Internal error - PDF Export is not possible"
DuetSS (talkcontribs)
Reply to "Other mPDF Functions"
Ablum010777 (talkcontribs)


I try to install Mpdf extension on my Wiki. However, when I render a Wiki page as PDF, I get only the text portions, but the graphics are not rendered. Is there a way to configure Mpdf to integrate the graphics in the rendered page?

2A02:908:1394:D840:3D14:6640:87F1:FF16 (talkcontribs)

Same problem here. (talkcontribs)

Had the same issue with a Wiki behind HTTP Basic Auth wall. The extension appears to fetch the images from the URL that is in the img-Tag, so maybe check your server logs and see if you need adjustments, for instance allow mpdf connect to your server.

host.example.com:443 - - [18/Jul/2020:15:34:36 +0000] "GET /w/images/a/a7/SomeImage.svg HTTP/1.0" 401 9165 "-" "-"
Reply to "No graphics with Mpdf"

Mpdf library outdated and causing errors and warnings

Summary by Kghbln

Tracked with task T227479.

Kghbln (talkcontribs)

The Mpdf library is outdated and is causing errors and warnings on PHP 7.2:

  • ErrorException from line 10894 of /../vendor/mpdf/mpdf/mpdf.php: PHP Deprecated: The each() function is deprecated.
  • ErrorException from line 30648 of /../vendor/mpdf/mpdf/mpdf.php: PHP Warning: A non-numeric value encountered
Kghbln (talkcontribs)

@Pastakhov: This is indeed spamming the error logs. It will be great if you could have a peep at this issue.

Reply to "Mpdf library outdated and causing errors and warnings"
D0388 (talkcontribs)


i have a problem with the last mw and mpdf,when i exported a pdf,it always became random code,i don`t know how to fix it,anybody can help me?

Reply to "Chinese random code"

How to: Some small settings and changes?

OOZ.MOO (talkcontribs)

Hi again, I need help regarding some issues I'm having with some settings for my PDF output. Would greatly appreciate your help:

-At the end of the PDF document, there's a footer which is printed out (A grey line) which I need to remove. I haven't found anywhere in the php codes where this line is produced. It's not the general footer, it's just one line which is there always after the last line of the last page. It casues sometime a new extra page to be added.

(Update:The footer is embeded in the Skin from Mediawiki. It's unrelated to the mPDF and must be taken out from the skins)

-Some special characters which are embeded into Wiki pages (for example "->" written by the tag "→" ) are not translated in the output. Can this be fixed somehow?

-Can I choose if the auto-generated Table of Contents to not be printed in the output? I need to keep them in the wiki online page, but don't want them in the PDF output. The same goes for the "Tooltips" which can be embeded into wiki page by the code "{{tip|" . Can you somehow tell mPDF to jump over these tags?

-My output layout is a two sided A5 page, and I need to have always the text and description on the left page(odd pages) and the pictures on the right (even pages). Is there anyway to achieve this automatically? I can reach it somehow with page breaks before or after the pictures, but that means doing it for every single entry I have in my Wiki page. Is there a hack to it maybe with the PHP codes?

-Lastly, have you managed to add the "collect and print different/all pages of a wiki into one single pdf file? Or do you have any perspective on this?

Thanks a million times for your time and effort in this extension.

Reply to "How to: Some small settings and changes?"
Return to "Mpdf" page.