Hi Folks,
I've been seaching the internet, but I cant seem to find a solution: I get this fatal error, when trying to create a pdf from a node:

Fatal error: Class 'DOMPDF' not found in /home/www/citiesonspeed.dk/modules/print/print_pdf/print_pdf.pages.inc on line 130

Whan can I do. Thanks!

Comments

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

Is dompdf still available? Maybe you re-installed the module and deleted the dompdf folder.

Mandrup’s picture

Hi - everything is in its right place and dompdf is still avaliable. I also mange to get one pdf created since I installed it, but then I get the fatal error.

dsy73’s picture

Same problem here. I tried to disable and renable "PDF Version" module but the problem still occurs.
Maybe it is because I installed the 1.8 version and revert to 1.7?

ceinmart’s picture

Version: 6.x-1.7 » 6.x-1.8
Assigned: Unassigned » ceinmart

I have the same situation, after upgrade to version : 1.8

Fatal error: Class 'DOMPDF' not found in /home/..../sites/all/modules/print/print_pdf/print_pdf.pages.inc on line 134

I already try uninstall the module (on .../admin/build/modules/uninstalls) , remove all files (print directory) and reinstall module + dom , reconfigure all ... and the error keeping occur.

the DOM is recognized by PRINT module and selected on .../admin/settings/print/pdf :
sites/all/modules/print/lib/dompdf-0.5.1/dompdf_config.inc.php

On the watchdog, no log are created...

ceinmart’s picture

Status: Postponed (maintainer needs more info) » Needs review

if need more information, please tell me , to provide all what you need to identify the reason for this issue.

jcnventura’s picture

Status: Needs review » Postponed (maintainer needs more info)

It works fine with me..

The only reason I can find for such an error after the upgrade is if the dompdf library folder is no longer installed, doesn't have the right read permissions or has moved the location since the previous install, but the module wasn't reconfigured.

João

ceinmart’s picture

Status: Postponed (maintainer needs more info) » Needs review

Ola João,

I like to remember the module is capable to recognized the dompdf , so , they are installed...

I changed all permission in the lib directory to 777 ( chmod -R 777 lib) and the error keep occur.

sftp> pwd
Remote working directory: /............./public_html/......../sites/all/modules/print
sftp> ls -l
cd l-rw-r--r--    1 onoonono onoonono    36337 May 12 22:11 CHANGELOG.txt
-rw-r--r--    1 onoonono onoonono      379 Nov 15  2007 CREDITS.txt
-rw-r--r--    1 onoonono onoonono     3734 Jun 15 19:04 INSTALL.txt
-rw-r--r--    1 onoonono onoonono    14940 Apr 23  2006 LICENSE.txt
-rw-r--r--    1 onoonono onoonono       70 Aug 23  2007 MAINTAINERS.txt
-rw-r--r--    1 onoonono onoonono     4180 Feb 19  2009 README.txt
drwxr-xr-x    2 onoonono onoonono     4096 Aug 19 23:31 css
drwxr-xr-x    2 onoonono onoonono     4096 Aug 19 23:31 icons
drwxrwxrwx    3 onoonono onoonono     4096 Sep  3 16:56 lib
-rw-r--r--    1 onoonono onoonono    18116 Aug 19 23:19 print.admin.inc
-rw-r--r--    1 onoonono onoonono      384 Aug 19 23:31 print.info
-rw-r--r--    1 onoonono onoonono     8936 Aug 19 23:09 print.install
-rw-r--r--    1 onoonono onoonono    26697 Aug 19 23:19 print.module
-rw-r--r--    1 onoonono onoonono    24769 Aug 19 23:19 print.pages.inc
-rw-r--r--    1 onoonono onoonono     1748 Jul  9 09:00 print.tpl.php
drwxr-xr-x    2 onoonono onoonono     4096 Aug 19 23:31 print_mail
drwxr-xr-x    2 onoonono onoonono     4096 Aug 19 23:31 print_pdf
drwxr-xr-x    2 onoonono onoonono     4096 Aug 19 23:31 tests
drwxr-xr-x    2 onoonono onoonono     4096 Aug 19 23:31 translations

sftp> cd lib
sftp> ls -l
-rw-r--r--    1 onoonono onoonono      191 Apr 27 19:53 README.txt
drwxrwxrwx    5 onoonono onoonono     4096 Sep  3 17:01 dompdf-0.5.1

sftp> cd dompdf-0.5.1
sftp> ls -l
-rwxrwxrwx    1 onoonono onoonono    31788 Jul  7  2006 ChangeLog
-rwxrwxrwx    1 onoonono onoonono     1199 Jul  7  2006 HACKING
-rwxrwxrwx    1 onoonono onoonono     4519 Jul  7  2006 INSTALL
-rwxrwxrwx    1 onoonono onoonono    26430 Jul  7  2006 LICENSE.LGPL
-rwxrwxrwx    1 onoonono onoonono    10032 Jul  7  2006 README
-rwxrwxrwx    1 onoonono onoonono     5059 Jul  7  2006 TODO
-rwxrwxrwx    1 onoonono onoonono     7964 Jul  7  2006 dompdf.php
-rwxrwxrwx    1 onoonono onoonono     6847 Jul  7  2006 dompdf_config.inc.php
drwxrwxrwx    2 onoonono onoonono     4096 Jul  7  2006 include
drwxrwxrwx    4 onoonono onoonono     4096 Jul  7  2006 lib
-rwxrwxrwx    1 onoonono onoonono     7967 Jul  7  2006 load_font.php
drwxrwxrwx    4 onoonono onoonono     4096 Jul  7  2006 www

If you still no idea what happen here, please tellme the file and code (line number, function name) what I need to debug . I'm not PHP developer, but I learn it if need, and get some help with friends...

Não sei se em Portugual vocês dizem isso, mas me "passe o caminho das pedras" que eu me viro por aqui..

Abraço
Cesar

jcnventura’s picture

Status: Needs review » Postponed (maintainer needs more info)

It is capable of recognizing the dompdf, but if you install it in a certain location, configure it at that location and then move it, the module will not 'discover' the new location automatically until you re-configure the module.

As to where you have to look, start in print_pdf/print_pdf.pages.inc, specifically the _print_pdf_dompdf().

João

ceinmart’s picture

Status: Active » Needs review

João,

I alter the code bellow on the page_pdf.pages.inc

function _print_pdf_dompdf($print, $html, $filename) {
  $print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
  $print_pdf_paper_size = variable_get('print_pdf_paper_size', PRINT_PDF_PAPER_SIZE_DEFAULT);
  $print_pdf_page_orientation = variable_get('print_pdf_page_orientation', PRINT_PDF_PAGE_ORIENTATION_DEFAULT);
  $print_pdf_content_disposition = variable_get('print_pdf_content_disposition', PRINT_PDF_CONTENT_DISPOSITION_DEFAULT);
  require_once($print_pdf_pdf_tool);
// -------------CODE ADDED HERE
  print($print_pdf_pdf_tool);
  print(' - ');
  print(variable_get('DOMPDF_DIR', ':nulo:'));

when execute to generate a PDF this is the output

sites/all/modules/print/lib/dompdf-0.5.1/dompdf_config.inc.php - :nulo:
Fatal error: Class 'DOMPDF' not found in /.../......./public_html/........./sites/all/modules/print/print_pdf/print_pdf.pages.inc on line 137

Look, the DOMPDF_DIR aren't set . I don't have any experience with PHP but I believed this should exists..
Do you have any suggestion where I can put a debug code ?

Veja que o a variavel DOMPDF_DIR não foi definida, não tenho experiencia com PHP mas acredito que ela deveria contar algum valor. As permissões nos diretórios lib e do DOM estão ok.
Sugere colocar algum código para debug em algum ponto estratégico para identificar isso?

jcnventura’s picture

Status: Postponed (maintainer needs more info) » Active

Olá Cesar,

Keep it in English, please, as this may be useful to others in the future when they search for it.

I also think that the DOMPDF_DIR should be set, but as you can see the only reason for that is if the require_once fails.

In my setup, and with the value provided for $print_pdf_pdf_tool, the dompdf library is called. In your case, it seems it isn't. The only normal reason would be if that dompdf file can't be found in that location. That may be because its not there or because of access rights, but you've already shown that not to be the case, so I have no idea what's the problem with your system.

João

ceinmart’s picture

Status: Needs review » Active

Hi João,

I don't know if have a mistake on the code used because I don't have experience with PHP. I use the function variable_get and maybe this is not the correct way to get the DOMPDF_DIR

First I have doubt if the require_once are working, so I put some print on the DOM files... and works...

After new tests I believed the problem is a miss of call the __autoload function.
This time I alter the file dompdf_config.inc.php , and put new prints:

....
/**
 * The root of your DOMPDF installation
 */
define("DOMPDF_DIR", realpath(dirname(__FILE__)));
// ------------- CODE ADDED HERE - START
print('|-- REALPATH:'.realpath(dirname(__FILE__)).' --|');
print('|-- DOMPDF_DIR:'.DOMPDF_DIR.' --|');
// ------------- CODE ADDED HERE - FINISH
...
function DOMPDF_autoload($class) {
  $filename = mb_strtolower($class) . ".cls.php";
// ------------- CODE ADDED HERE
  print('|-- DOMPDF_autoload: '.DOMPDF_INC_DIR. "$filename".'--|');
  require_once(DOMPDF_INC_DIR . "/$filename");
}

if ( !function_exists("__autoload") ) {
  /**
   * Default __autoload() function
   *
   * @param string $class
   */
// ------------- CODE ADDED HERE - START
print('|-- DEFINE _AUTOLOAD --|');
  function __autoload($class) {
    DOMPDF_autoload($class);
  }
}
....

The result:

|-- REALPATH:/............/public_html/......../sites/all/modules/print/lib/dompdf-0.5.1 --||-- DOMPDF_DIR:/............/public_html/......../sites/all/modules/print/lib/dompdf-0.5.1 --||-- DEFINE _AUTOLOAD --|
Fatal error: Class 'DOMPDF' not found in /............/public_html/......./sites/all/modules/print/print_pdf/print_pdf.pages.inc on line 134

Miss the print of '|-- DOMPDF_autoload: .... --|'
There is the place where call the DOMPDF class file.

But I not found where is made the call of __autoload function...

ceinmart’s picture

After some research I discovery the function __autoload is a new feature on the PHP 5 and is called automatically when a new class are instantiate.

But in this situation they not working...

I looking for some environment configuration where can change this behave and I not found... some tips?

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

Do you have PHP5 installed? If you're using PHP4 you simply can't use dompdf as it requires PHP5.

ceinmart’s picture

Status: Postponed (maintainer needs more info) » Active

Yes, is PHP5 (copied from my cPanel on my host manager)
Versão do PHP 5.2.6

I alter the code to:

if ( !function_exists("__autoload") ) {
  /**
   * Default __autoload() function
   *
   * @param string $class
   */
print('|-- DEFINE _AUTOLOAD --|');
print('|-- PHP version: '.phpversion().' --|');
  function __autoload($class) {
  print('|-- _autoload --|');
    DOMPDF_autoload($class);
  }
}
|-- REALPATH:/home/imartins/public_html/informix/sites/all/modules/print/lib/dompdf-0.5.1 --||-- DOMPDF_DIR:/home/imartins/public_html/informix/sites/all/modules/print/lib/dompdf-0.5.1 --||-- DEFINE _AUTOLOAD --||-- PHP version: 5.2.6 --|
Fatal error: Class 'DOMPDF' not found in /home/imartins/public_html/informix/sites/all/modules/print/print_pdf/print_pdf.pages.inc on line 134
jcnventura’s picture

Still no idea, but I do find it weird that the require_once works, but the DOMPDF_DIR is not defined after that..

That's unusual, and maybe there is some PHP setting in your system that causing that. When you figure it out, I am sure that dompdf will start working.

ceinmart’s picture

I already start talking with my host provider support, if have any solution I will post here...

jcnventura’s picture

Actually, looking back, remove the variable_get from the DOMPDF_DIR debug. Just do it like this:

var_dump(DOMPDF_DIR);

jcnventura’s picture

Status: Active » Closed (fixed)

No further info in two weeks. Closing the issue.

marita93’s picture

Status: Closed (fixed) » Active

I finally did this upgrade and had the same error. is #17 the answer? Could you explain what file to make that change in?

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

I never found out the origin of the problem for ceinma. Are you getting the exact same error (Fatal error: Class 'DOMPDF' not found).

The suggestion in #17 was not a solution, it was a request for further debugging in order to discover the source of the problem. He never replied back, so I closed the issue.

This is 99.99% sure a problem with your setup, but in case there really is the 0.01% chance of a bug in the module, I would like to know what is causing this.

So, if you're willing to debug the print_pdf module to discover why the dompdf include is not being successful, I would appreciate if you could share your findings here.

marita93’s picture

Yes, I am getting the exact same error. I found a change to the following function in the dompdf_config.inc.php file , line 193 is changed to add the DOMPDF_INC_DIR to the filename. It didn't make the error go away, I think I need to add a call to this function to your module.

/**
* DOMPDF autoload function
*
* If you have an existing autoload function, add a call to this function
* from your existing __autoload() implementation.
*
* @param string $class
*/
function DOMPDF_autoload($class) {
$filename = DOMPDF_INC_DIR . "/" . mb_strtolower($class) . ".cls.php";
require_once(DOMPDF_INC_DIR . "/$filename");
}

jcnventura’s picture

I don't think you need that function, as the require_once is already in the module.

However, googling for the error, I found that this problem may be fixed by inserting
spl_autoload_register('DOMPDF_autoload');

Just after the require_once($print_pdf_pdf_tool); line in the _print_pdf_dompdf() function in print_pdf/print_pdf.pages.inc.

Can you try it and tell me if it works for you?

marita93’s picture

I tried it and it works! I am now happily producing PDFs. Thank you!

jcnventura’s picture

Status: Postponed (maintainer needs more info) » Fixed

Thanks for letting me know..

I have added the above line to the current code in CVS.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mfby2k’s picture

Version: 6.x-1.8 » 7.x-1.x-dev
Issue tags: +pdf generation dompdf

I don't think you need that function, as the require_once is already in the module.

However, googling for the error, I found that this problem may be fixed by inserting
spl_autoload_register('DOMPDF_autoload');

Just after the require_once($print_pdf_pdf_tool); line in the _print_pdf_dompdf() function in print_pdf/print_pdf.pages.inc.

Can you try it and tell me if it works for you?

i tried this mathod but its not working...
on my site DAEnotes.com

Ben Coleman’s picture

We're getting this error in 7.x-1.0, despite the code from #22 being already being in print_pdf/print_pdf.pages.inc.

Ben Coleman’s picture

Status: Closed (fixed) » Active
Ben Coleman’s picture

In 7.x-1.0, this goes away if you use DOMPDF-0.6.0 (currently Beta3), instead of using DOMPDF-0.5.2. Should 7.x be documented as requiring 0.6.0?

jcnventura’s picture

Status: Active » Closed (fixed)

Please do not resurrect a 3-year old issues for something only slightly related.

I've tested the module with dompdf 0.5.2 and it works, and that's the reason why >= 0.6 is not a requirement. There's some warnings for duplicate definition of constants, but nothing major. Certainly not a fatal error.