Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
jcnventura CreditAttribution: jcnventura commentedIs dompdf still available? Maybe you re-installed the module and deleted the dompdf folder.
Comment #2
Mandrup CreditAttribution: Mandrup commentedHi - 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.
Comment #3
dsy73 CreditAttribution: dsy73 commentedSame 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?
Comment #4
ceinmart CreditAttribution: ceinmart commentedI have the same situation, after upgrade to version : 1.8
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...
Comment #5
ceinmart CreditAttribution: ceinmart commentedif need more information, please tell me , to provide all what you need to identify the reason for this issue.
Comment #6
jcnventura CreditAttribution: jcnventura commentedIt 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
Comment #7
ceinmart CreditAttribution: ceinmart commentedOla 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.
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
Comment #8
jcnventura CreditAttribution: jcnventura commentedIt 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
Comment #9
ceinmart CreditAttribution: ceinmart commentedJoão,
I alter the code bellow on the page_pdf.pages.inc
when execute to generate a PDF this is the output
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?
Comment #10
jcnventura CreditAttribution: jcnventura commentedOlá 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
Comment #11
ceinmart CreditAttribution: ceinmart commentedHi 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 result:
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...
Comment #12
ceinmart CreditAttribution: ceinmart commentedAfter 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?
Comment #13
jcnventura CreditAttribution: jcnventura commentedDo you have PHP5 installed? If you're using PHP4 you simply can't use dompdf as it requires PHP5.
Comment #14
ceinmart CreditAttribution: ceinmart commentedYes, is PHP5 (copied from my cPanel on my host manager)
Versão do PHP 5.2.6
I alter the code to:
Comment #15
jcnventura CreditAttribution: jcnventura commentedStill 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.
Comment #16
ceinmart CreditAttribution: ceinmart commentedI already start talking with my host provider support, if have any solution I will post here...
Comment #17
jcnventura CreditAttribution: jcnventura commentedActually, looking back, remove the variable_get from the DOMPDF_DIR debug. Just do it like this:
var_dump(DOMPDF_DIR);
Comment #18
jcnventura CreditAttribution: jcnventura commentedNo further info in two weeks. Closing the issue.
Comment #19
marita93 CreditAttribution: marita93 commentedI finally did this upgrade and had the same error. is #17 the answer? Could you explain what file to make that change in?
Comment #20
jcnventura CreditAttribution: jcnventura commentedI 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.
Comment #21
marita93 CreditAttribution: marita93 commentedYes, 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");
}
Comment #22
jcnventura CreditAttribution: jcnventura commentedI 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?
Comment #23
marita93 CreditAttribution: marita93 commentedI tried it and it works! I am now happily producing PDFs. Thank you!
Comment #24
jcnventura CreditAttribution: jcnventura commentedThanks for letting me know..
I have added the above line to the current code in CVS.
Comment #26
mfby2k CreditAttribution: mfby2k commentedi tried this mathod but its not working...
on my site DAEnotes.com
Comment #27
Ben Coleman CreditAttribution: Ben Coleman commentedWe're getting this error in 7.x-1.0, despite the code from #22 being already being in print_pdf/print_pdf.pages.inc.
Comment #28
Ben Coleman CreditAttribution: Ben Coleman commentedComment #29
Ben Coleman CreditAttribution: Ben Coleman commentedIn 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?
Comment #30
jcnventura CreditAttribution: jcnventura commentedPlease 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.