Topic on Project:Current issues

Jump to: navigation, search
Yolo33s (talkcontribs)

After installing PdfExport Extension (v3.2.0) for mediawiki 1.27.0, I have the following error message :

Fatal error: Call to undefined method Article::preSaveTransform() in /var/www/wiki/extensions/PdfExport/converters/HtmlDocPdfConverter.php on line 151

This comment was hidden by Seb35 (history)
This comment was hidden by Seb35 (history)
Seb35 (talkcontribs)

@Yolo33s: This extension is hardly maintained since some time. In fact the line you pointed probably didn’t work since MediaWiki 1.18. I just solved a number of issues I experimented when launching this extension with MediaWiki 1.28alpha, PHP 7.0 and Dompdf 0.7 (installed with Composer), whose this issue. Finally it worked with Dompdf – I didn’t tested other backends. When the change I04eda179bab689e29b9f26caf10807f4136afa3f will be merged, it should work, but you will have to install the very last version (it will be available on ). (talkcontribs)

@Seb35: Thanks for support. I first tried to install dompdf 0.7 with composer but as I don't master it I was not sure about what I was doing. The unzipped dompdf folder is in /usr/bin/dompdf. In LocalSettings.php, I added "require_once '/usr/bin/dompdf/';" but when I try to print a page, I get an error message saying that no pdf converter software has been found.

Is it good to place the require_once in LocalSettings.php ? I also tried in index.php. More precisions on how to install dompdf would be much appreciated.


Seb35 (talkcontribs)

I tested the following commands (probably you did some of these):

  1. Download Dompdf 0.7 from GitHub
  2. Unzip it in the MediaWiki directory, next to LocalSettings.php, the subdirectory is named "dompdf"
  3. Add require_once __DIR__ . '/dompdf/'; in your LocalSettings.php
  4. Download the patched version of PdfExport from my website (when the change above will be merged, it will be available in the "official" version on )
  5. Unzip it as usual in extensions/ (if you had a previous extensions/PdfExport move it to another location or delete it)
  6. It should work

I guess you are under Linux, right? If so, the path /usr/bin is reserved for general commands, but not for librairies (as is Dompdf); I said above to put it in the MediaWiki directory, it is probably a good place; else web applications sometimes have a subdirectory "lib" where are the external librairies (MW doesn’t have this subdirectory, external librairies are in the subdirectory "vendor" managed by Composer -- prepared by the release manager in the case of the tarball).

Manilal (talkcontribs)

@Seb35 installed dompdf using composer and used your patch. But when I click on Print as PDF link it gives me a blank page. Here is my LocalSettings.php:

require_once "$IP/extensions/PdfExport/PdfExport.php";

Seb35 (talkcontribs)

Probably some file is missing, but we need more informations to find what file is missing.

  1. Check in your webserver logs, there is perhaps some PHP messages (/var/log/apache2/error.log or /var/log/nginx/error.log)
  2. Try to enable
    $wgShowExceptionDetails = true;
    and retry to display the PDF: is there some explicit error message?
  3. Configure
    $wgDebugLogFile = 'debug.log';
    and retry to display the PDF: is there some useful error message in this file?
Manilal (talkcontribs)

@Seb35 I'm sorry for the delayed response, I didn't notice your reply.

I enabled both the above configs and got a bunch of messages in debug.log. I think the following is related to DomPdf.

[exception] [WLPQoUWN-nHgCzghCAxhXAAAABg] /mediawiki/index.php?title=Special:Pdfprint&page=Downloads   Dompdf\Exception from line 704 of /home/www/html/mediawiki/vendor/dompdf/dompdf/src/Css/Stylesheet.php: Invalid CSS selector syntax: missing attribute name

#0 /home/www/html/mediawiki/vendor/dompdf/dompdf/src/Css/Stylesheet.php(879): Dompdf\Css\Stylesheet->_css_selector_to_xpath(string)

#1 /home/www/html/mediawiki/vendor/dompdf/dompdf/src/Dompdf.php(732): Dompdf\Css\Stylesheet->apply_styles(Dompdf\Frame\FrameTree)

#2 /home/www/html/mediawiki/extensions/PdfExport/converters/DomPdfConverter.php(102): Dompdf\Dompdf->render()

#3 /home/www/html/mediawiki/extensions/PdfExport/PdfExport_body.php(111): DomPdfConverter->outputPdf(array, array)

#4 /home/www/html/mediawiki/includes/specialpage/SpecialPage.php(522): SpecialPdf->execute(NULL)

#5 /home/www/html/mediawiki/includes/specialpage/SpecialPageFactory.php(576): SpecialPage->run(NULL)

#6 /home/www/html/mediawiki/includes/MediaWiki.php(283): SpecialPageFactory::executePath(Title, RequestContext)

#7 /home/www/html/mediawiki/includes/MediaWiki.php(851): MediaWiki->performRequest()

#8 /home/www/html/mediawiki/includes/MediaWiki.php(512): MediaWiki->main()

#9 /home/www/html/mediawiki/index.php(43): MediaWiki->run()

#10 {main}

Please let me know if you can interpret anything from this messages. I have enabled selinux in this server (CentOS-7 with Apache Httpd), but couldn't find anything related to httpd in audit.log. (talkcontribs)

Thank you for the tips @Seb35. I did everything listed above. Now it is installed but when I print an article I get an error message Exception encountered, of type "Dompdf\Exception" without more informations. This is a blank page. I checked that all requirements are OK (Dom extension, GD extension, MBString, php-font-lib, php-svg-lib) and they are, then I restarted apache...

Do you have any idea about this error message. I read some posts about Dompdf Exception but generally the error message is more precise than just "Dompdf\Exception".

For information, I'm on Ubuntu 16.04 with PHP 5.6 and I run a 1.27.0 version of MW.


Seb35 (talkcontribs)

Great! At least the MW part seems to work. I didn’t have this exception myself – different config: Debian+PHP7, but yours seems to be quite good also. Can you add ini_set( 'display_errors', 1 ); on the top of your LocalSettings.php? It could display a more detailled information about the exception (you will have to remove it in production).

Yolo33s (talkcontribs)

Yes I also thought to display errors but unfortunately it is not more verbose...Only a strict standard warning unrelated to PdfExport or Dompdf. I wonder if an installation with composer would be safer but I do not feel comfortable with that.

Seb35 (talkcontribs)

If you feel comfortable with command line (quick guide: directories are separated by a slash "/", the main commands are "cd the-directory-you-want-go-to" and "ls" to display the content of the directory), you can install Composer inside the main MediaWiki directory (instructions), then add Dompdf as dependency by creating the file composer.local.json in MediaWiki directory (next to LocalSettings.php) with the content:

   "require": {
      "dompdf/dompdf": "*"

and executing (in command line in MediaWiki directory) "composer update --no-dev". If you install it with Composer, remove the require_once from LocalSettings.php (else it could be installed two times). There is a guide for Composer on Composer/For extensions. Thanks for your perseverance! (talkcontribs)

And thank you very much for your help @Seb35, I really need to make this extension work. When running "composer update --no-dev" it seems that this is mbstring and gd extension the problem. It is missing. What I don't understand is that I'm using php 5.6 and it requires mbstring and gd extension for php7...Strange. Anyway, it is installed but I still have the same exact error message. Note that in my mediawiki installation folder, the .json file is named composer.json and not composer.local.json. But if dompdf had not been installed, I would have had another error message.

Ma persévérance atteint ses limites.

Seb35 (talkcontribs)

Don’t you have some sysadmin or a geeky person near you? It becomes difficult to follow remotely. For Composer I guess there are dependency issues, probably because some dependencies require PHP7, so probably a bad idea to try in this direction, stay with your downloaded version 0.7 of dompdf. And it is absolutely required for PdfExport, so you (or anybody who could help you) have to make Dompdf work to make PdfExport work. Perhaps add also ini_set('error_reporting', E_ALL); in your LocalSettings.php.

If it cannot work, I tried to install Extension:Collection but, as I was afraid of, it is horribly difficult to install. And an external solution but functionning without any burden for the MW admin is to use the link 'Printable version' in the sidebar section Tools, then use the Print feature of the browser and select 'Print in file'. Depending on the browser, it will save in a Postscript file and/or PDF file. With this way to export PDF, the result can be different from a brower to another (e.g. I was surprised of a document where the font size was about the double between Firefox and Chrome -- it was quite small with Chrome and quite big with Firefox). (talkcontribs)

Yes I already tried collection, and I already add ini_set('error_reporting', E_ALL); in LocalSettings.php. I think dompdf is installed because wether I install it through composer or simple folder, I had the same error message at the end. I will wait for the return of a sysadmin to debug this issue. Anyway thanks a lot for support. (talkcontribs)

@Seb35 I did it ! I found on the general support someone with a completely different problem who needed to run the "jobs". After a php maintenance/runJobs.php, I could print articles to pdf.

I'm still convinced that the mediawiki documentation needs drastic improvements.

Seb35 (talkcontribs)

Ok, I didn’t know it could have an influence, but it’s great! Happy the problem was solved! (and aggree about documentation, it’s a lot of work, you’re welcome if you want to add something, but this thread will probably help other people also :)

Edrimon (talkcontribs)

Hi, Thank you for your valuable information. I installed as instructed in this document, but I get the following output for Greek in my wiki in UTF-8.

Any ideas? its common UTF-8 , should n't it work?

Scroom (talkcontribs)

@Seb35 I get the following error If I try to produce a PDF out of a wiki article:

Exception encountered, of type "Dompdf\Exception" [1ba58343a430deff683c3f41] /wiki/index.php?title=Spezial:PDF-Druck&page=Kollegium Dompdf\Exception from line 704 of /var/www/html/wiki/dompdf/src/Css/Stylesheet.php: Invalid CSS selector syntax: missing attribute name Backtrace:

  1. 0 /var/www/html/wiki/dompdf/src/Css/Stylesheet.php(879): Dompdf\Css\Stylesheet->_css_selector_to_xpath(string)
  2. 1 /var/www/html/wiki/dompdf/src/Dompdf.php(732): Dompdf\Css\Stylesheet->apply_styles(Dompdf\Frame\FrameTree)
  3. 2 /var/www/html/wiki/extensions/PdfExport/converters/DomPdfConverter.php(102): Dompdf\Dompdf->render()
  4. 3 /var/www/html/wiki/extensions/PdfExport/PdfExport_body.php(111): DomPdfConverter->outputPdf(array, array)
  5. 4 /var/www/html/wiki/includes/specialpage/SpecialPage.php(479): SpecialPdf->execute(NULL)
  6. 5 /var/www/html/wiki/includes/specialpage/SpecialPageFactory.php(576): SpecialPage->run(NULL)
  7. 6 /var/www/html/wiki/includes/MediaWiki.php(282): SpecialPageFactory::executePath(Title, RequestContext)
  8. 7 /var/www/html/wiki/includes/MediaWiki.php(745): MediaWiki->performRequest()
  9. 8 /var/www/html/wiki/includes/MediaWiki.php(519): MediaWiki->main()
  10. 9 /var/www/html/wiki/index.php(43): MediaWiki->run()
  11. 10 {main}

Do you maybe have an idea what to do?

Reply to "PdfExport does not work on 1.27.0"