Extension talk:Pdf Export Dompdf

Code has been updated
I took the liberty of updating the code to be compatible with the latest versions of Pdf Export, DOMPDF, and MediaWiki. It should work flawlessly. No problems with autoload functionality if you're running PHP 5.1.2 or higher (See: spl_autoload_register). Temp directory has been changed to use system temp directory. Change that back to $wgTmpDirectory (don't forget to globalize it) if you have any issues. All modifications have been noted in the source code. Feel free to modify as needed.

PDFExport_body.php
We had a problem with undefined variables. So we changes the file in the line 138 We altered the last line, the two lines above a new. After this change everything works fine.

Added: 27 January 2009

Problems with nontrivial wikitext
Running MediaWiki 1.13.2, PDFExport 2.0 with dompdf changes described here.

A lot of very simple pages print fine with dompdf; however, some pages give errors on display. For example, the following simple table in a MW page gives a 'File does not being with "%PDF-"...' error on Safari under Mac OS X:

If you remove the nowiki, it works. (EDIT) However, the following code which does not use nowiki and does not number the table cell also doesn't work:

=test=

test3
EDIT: I've figured out that the problem above may be related to the generation of tables of contents. If I turn off this with, the PDF print works OK. However, on a very large page which is just a string of headers and pre blocks, I still get the "File does not begin with %PDF-" error when I export to PDF.

We're also getting the following written to the PDF on some pages:

exception 'DOMPDF_Exception' with message 'Box property calculation requires containing block width' in /usr/local/apache2/htdocs  /wiki/extensions/PdfExport/dompdf/include/block_frame_reflower.cls.php:111 Stack trace:
 * 1) 0 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/dompdf/include/block_frame_reflower.cls.php(368): Block_Frame_Reflower->_calculate_restricted_width
 * 2) 1 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/dompdf/include/frame_decorator.cls.php(387): Block_Frame_Reflower->reflow
 * 3) 2 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/dompdf/include/block_frame_reflower.cls.php(408): Frame_Decorator->reflow
 * 4) 3 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/dompdf/include/frame_decorator.cls.php(387): Block_Frame_Reflower->reflow
 * 5) 4 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/dompdf/include/block_frame_reflower.cls.php(408): Frame_Decorator->reflow
 * 6) 5 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/dompdf/include/frame_decorator.cls.php(387): Block_Frame_Reflower->reflow
 * 7) 6 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/dompdf/include/block_frame_reflower.cls.php(408): Frame_Decorator->reflow
 * 8) 7 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/dompdf/include/frame_decorator.cls.php(387): Block_Frame_Reflower->reflow
 * 9) 8 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/dompdf/include/table_cell_frame_reflower.cls.php(115): Frame_Decorator->reflow
 * 10) 9 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/dompdf/include/frame_decorator.cls.php(387): Table_Cell_Frame_Reflower->reflow
 * 11) 10 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/dompdf/include/table_row_frame_reflower.cls.php(70): Frame_Decorator->reflow
 * 12) 11 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/dompdf/include/frame_decorator.cls.php(387): Table_Row_Frame_Reflower->reflow
 * 13) 12 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/dompdf/include/table_frame_reflower.cls.php(468): Frame_Decorator->reflow
 * 14) 13 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/dompdf/include/frame_decorator.cls.php(387): Table_Frame_Reflower->reflow
 * 15) 14 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/dompdf/include/block_frame_reflower.cls.php(408): Frame_Decorator->reflow
 * 16) 15 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/dompdf/include/frame_decorator.cls.php(387): Block_Frame_Reflower->reflow
 * 17) 16 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/dompdf/include/page_frame_reflower.cls.php(78): Frame_Decorator->reflow
 * 18) 17 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/dompdf/include/frame_decorator.cls.php(387): Page_Frame_Reflower->reflow
 * 19) 18 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/dompdf/include/dompdf.cls.php(417): Frame_Decorator->reflow
 * 20) 19 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/PdfExport_body.php(136): DOMPDF->render
 * 21) 20 /usr/local/apache2/htdocs/wiki/extensions/PdfExport/PdfExport_body.php(171): SpecialPdf->outputpdf(Array, ' --portrait ', 'Letter')
 * 22) 21 /usr/local/apache2/htdocs/wiki/includes/SpecialPage.php(534): SpecialPdf->execute(NULL)
 * 23) 22 /usr/local/apache2/htdocs/wiki/includes/Wiki.php(224): SpecialPage::executePath(Object(Title))
 * 24) 23 /usr/local/apache2/htdocs/wiki/includes/Wiki.php(55): MediaWiki->initializeSpecialCases(Object(Title), Object(OutputPage), Object(WebRequest))
 * 25) 24 /usr/local/apache2/htdocs/wiki/index.php(93): MediaWiki->initialize(Object(Title), NULL, Object(OutputPage), Object(User), Object(WebRequest))
 * 26) 25 {main}

VIngogly 16:15, 6 February 2009 (UTC)

Noted
I have taken notice of your problem. I will look into a fix, but I must say right off the bat that it is a limitation of the DOMPDF class itself (and not the fault of this extension, per se). The class, though it works stupendously, is still quirky. The author seems to have abandoned it, but I will see about picking up where he left off.

Invalid argument supplied for foreach
i've got another problem with the extension, getting this warning: (I'm using MediaWiki 1.12.)

any ideas? 19:13, 26 November 2008 (UTC)


 * I have the same problem with MediaWiki 1.13.2 Msauter 14:15, 1 December 2008 (UTC)

Class 'DOMPDF' not found
I've got dompdf and the extension both installed, but it looks like it's not picking up an include file somewhere. The configuration is right nearest I can tell also. I'm using MediaWiki 1.12. --N0ctrnl 21:01, 28 March 2008 (UTC) [Fri Mar 28 15:55:08 2008] [error] [client 10.1.1.1] PHP Fatal error: Class 'DOMPDF' not found in /var/www/html/wiki/extensions/PdfExport/PdfExport.php on line 142, referer: http://server/wiki/index.php/Main_Page


 * From looking at the output (and experimenting with some includes), it looks like the dompdf/include/*.cls.php files aren't being loaded properly. If I manually include "$IP/dompdf/include/dompdf.cls.php", the DOMPDF class error goes away and another pops up.  If I continue doing that with the cls.php files that hold each missing class, it continues to knock out class errors.  The problem with that is that you'd have to include a ton of them in order to get it to work.


 * Now, the line in the dompdf_config.inc.php file has this line in it

function DOMPDF_autoload($class) { $filename = mb_strtolower($class). ".cls.php"; require_once(DOMPDF_INC_DIR . "/$filename"); }


 * That should pick up the right files that hold the class info unless I'm missing something. It just isn't.  Then, after it has included all of them, the PdfExport.php file includes the dompdf_config.inc.php on line 183 with the following:

require_once("$IP/extensions/dompdf/dompdf_config.inc.php");


 * Anybody else seeing errors like this or can point me in the right direction to debug it? --168.166.124.100 21:25, 8 April 2008 (UTC)

-- I have the exact same : Fatal error: Class 'DOMPDF' not found in C:\wamp\mediawiki-1.10.0\extensions\PdfExport\PdfExport.php on line 142

but since php isn't my mother tong, I have a hard time debugging it. I dumbly used the code provided on the extension's page.

brice 05:56, 11 April 2008 (UTC)

==> ok, I got it from dompdf\dompdf_config.inc.php :

So I might try to add it to the mediawiki/include/AutoLoader.php file. but i sounds quite odd... I'll try

brice 213.30.139.168 08:03, 11 April 2008 (UTC)

okay okay !! last but not least : http://sourceforge.net/forum/message.php?msg_id=4819436

so becomes

and it now works like a charm.

brice 213.30.139.168 08:48, 11 April 2008 (UTC)


 * Excellent work. I looked at the same thread on SF, but just couldn't get it working right away so I let it sit on the back burner.  Kudos to you for getting it done.  I like dompdf much better than the alternatives. N0ctrnl 16:01, 25 April 2008 (UTC)


 * Excellent work indeed!!! But should this tip/hint not be put on the main page under install?!? I think this is not only a hint, it more an advice to fulfill the install instructions... I was searching around for about an hour until I found it here... --DrTrigon 20:12, 9 July 2008 (UTC)

Okay - the above doesn't work for me. I edited dompdf_config.inc.php, replaced the autoloader with the code above and -it. I am still getting the same errors.

The Class DOMPDF is not found in Pdfexport.php on line 142

My "helloworld.php" script for dompdf works, so I know its something the mediawiki environment is doing that is causing it to fail. Aside from editing dompdf_config.php is there anything else I can do?? --99.232.79.240 09:13, 17 December 2008 (UTC)

class dompdf
add

to your LocalSettings.php
 * Did that already. The extension wouldn't be loading up at all without it :) I've checked and double checked, and just can't figure out what's up. --N0ctrnl 18:47, 6 April 2008 (UTC)

Keine Installation möglich / NO Installation possible

PHP sagt / PHP says: The Class DOMPDF is not found in Pdfexport.php on line 142