Extension talk:Mpdf

Get a HTTP500 Error when try to use Mpdf

1
Sarotar (talkcontribs)

Hello there,

so, I have installed the extension as stated in the extension description.

When I try to export a pdf using the link https://somedomain.de/index.php?somepage&action=mpdf all I get is an HTTP500 Error Page.

Is that a known issue? I gladly will provide more Details or Logs if needed.

Thank you

Reply to "Get a HTTP500 Error when try to use Mpdf"

Хак, чтобы заработал экспорт

1
37.214.26.60 (talkcontribs)

1.В корне вики запускаем установку mpdf композером:


composer require mpdf/mpdf


Поставится восьмая версия mpdf, которая работает с пхп8.


2.В папке самого раcширения Mpdf удаляем папку с библиотекой mpdf.


3.В файле MpdfAction вместо


$mpdf = new mPDF(...);


пишем


require_once __DIR__ . '/../../vendor/autoload.php';

$mpdf = new \Mpdf\Mpdf();

Reply to "Хак, чтобы заработал экспорт"
93.185.207.130 (talkcontribs)

PHP Fatal error:  Array and string offset access syntax with curly braces is no longer supported in /usr/share/mediawiki/extensions/Mpdf/vendor/mpdf/mpdf/mpdf.php on line 2349

93.185.207.130 (talkcontribs)

The extension is incompatible with php 8.0?

Reply to "php 8.0"

error on exporting to a pdf

4
Nicolas senechal (talkcontribs)

Hello,

I follow carefully the donwload part and the installation part but when I convert a article in pdf I have this error.

[b95a316a0df8370f20186161] 2022-07-05 15:14:27: Erreur fatale de type « Error »

I see befor other people who have the same (but I can"t find the topic...)

My configuration :

Produit Version
MediaWiki 1.37.1
PHP 8.1.2 (apache2handler)
MariaDB 10.4.22-MariaDB
ICU 70.1
Elasticsearch 6.8.23

So what I did wrong what I miss ?

thank you.

87.20.243.37 (talkcontribs)

I think that the extension is not compatible with php 8.

It uses a php syntax that is not more supported.

Try to migrate the wiki to php 7.x and it probably should resolve you problem.

Nicolas senechal (talkcontribs)

OK, I move to php 7.3.30 and I still have the same error.

Pooja2425 (talkcontribs)

87.20.243.37 But now php v7.3 life is going to end on 29th Nov, But need to upgrade php v8.0 .

with v8.0 mpdf 6.1 Extension:Mpdf is not woking .

pls suggest what we need to do ?

Reply to "error on exporting to a pdf"

When exporting a page, no images are inserted

3
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.

Alechandrop (talkcontribs)

No

I have this problem now

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

Does Mpdf Support Mediawiki Heavily formatted Tables?

1
GMShimokura (talkcontribs)

Hi. In my first attempts at using Mpdf, I get a PDF output.

MW 1.35.2, Mpdf 6.1.

However, I have many tables that do not render as seen on the screen nor similar to the output that would be produced by the browser print function.

Also I am creating a card game wiki with suit symbols formatted in different colours (ie red ♥) but the colours do not render either

Are tables and HTML characters supported?

Reply to "Does Mpdf Support Mediawiki Heavily formatted Tables?"

Mpdftags parsing and full copatibility with mPDF library

1
Michele.Fella (talkcontribs)

Methods 1 and 3 for mPDF Headers & Footers are deprecated


MpdfHooks parsing logic in mpdftags_Render function which replace open and close tag before re-including them in <> tags within did not allow me to use methods 2 and 4.


Not sure which are the "for security reason" for cirrent implementation, but simply passing the arguments of mpfdtags to mPDF would allow full compatibility with mPDF and enable usage of all possible mpdf control tags and HTML?

I changed the mpdftags_Render as following;

public static function mpdftags_Render( &$parser ) {
 // Get the parameters that were passed to this function
 $params = func_get_args();
 array_shift( $params );
 // Replace open and close tag for security reason
 //$values = str_replace( [ '<', '>' ], [ '<', '>' ], $params );
 // Insert mpdf tags between <!--mpdf ... mpdf-->
 $return = '<!--mpdf';
 /*
 foreach ( $values as $val ) {
  $return .= "<" . $val . " />\n";
 }
 */
 foreach ( $params as $val ) {
  $return .= "" . $val . "\n";
 }
 $return .= "mpdf-->\n";
 // Return mpdf tags as raw html
 return $parser->insertStripItem( $return );
}
Reply to "Mpdftags parsing and full copatibility with mPDF library"

HTML and PHP to Mpdftags

6
OOZ.MOO (talkcontribs)

Hi,

I have difficulty getting the mpdftags to work in Mediawiki. The example with the header and footer which is given in the Mediawiki entry for the extension, work just fine, but most of the HTML or mpdftags that I write in my wiki pages do not work. Is there any documentation on how to change, integrate or use the codes (that are provided in the documentation of the mpdf extension) for and in Mediawiki? what parameters should I change?

Would be very helpful to understand, and I'd really appreciate your help.


Pastakhov (talkcontribs)
OOZ.MOO (talkcontribs)

Took me long to figure out, since there's no documentation on the translation of the HTML tags to mediawiki.

OOZ.MOO (talkcontribs)

Hi Pastakhov. Thanks for your reply and sorry for my late reply. Actually using the tags is pretty easy, when you know how the tags translate from html to mediawiki to html:

{{#mpdftags: pagebreak}} -> <pagebreak\>


Obliva (talkcontribs)

+1 It would be very useful to have a list of translate tag from html to mediawiki

Obliva (talkcontribs)

For example, i want an orientation landscape for my table, but i can't find the mediawiki mpdftag...

Reply to "HTML and PHP to Mpdftags"

MPDF is not giving image with wiki 1.35

9
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)
MySQL 8
OS LINUX


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' );

$wgMpdfSimpleOutput=true;

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

/ttfontdata/

/tmp/

/graph_cache/

http://localhost/wiki135/index.php/Main_Page?title=Main_Page&action=mpdf



Please help me to fix this.


Thanks

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.

https://m.mediawiki.org/wiki/Extension:Mpdf

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"

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

6
145.253.133.129 (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)

@Seb35

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"?

Thanks!

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"