Welcome Guest, Not a member yet? Register   Sign In
Dompdf plugin "Fatal error: Class 'dompdf' not found" - probably a simple error
#1

[eluser]moresided[/eluser]
Hey

I've basically copied the to_pdf_pi.php plugin and dompdf folder from BambooInvoice.
But for some reason I'm getting the error:

Fatal error: Class 'dompdf' not found in {my root}\system\plugins\to_pdf_pi.php on line 15

This is the full code of to_pdf_pi.php

Code:
function pdf_create($html, $filename, $stream=TRUE)
{
    require_once(BASEPATH."plugins/dompdf/dompdf_config.inc.php");
  //require_once("dompdf/dompdf_config.inc.php");
    
    $dompdf = new DOMPDF();
    $dompdf->set_paper("a4", "portrait");
    $dompdf->load_html($html);
    $dompdf->render();
    if ($stream) {
        $dompdf->stream($filename.".pdf");
    }
    write_file("./invoices_temp/invoice_$filename.pdf", $dompdf->output());
}

Have done some rooting around on google and here and can't find anyone with exactly the same problem.

Any ideas? Thanks in advance!
#2

[eluser]moresided[/eluser]
Anyone got any ideas?
Is there any common reason why a class will show as 'not found' like this?
#3

[eluser]Unknown[/eluser]
Hi!
You probably use your own __autoload function.
You should add the following code inside this function:

Code:
if(function_exists('DOMPDF_autoload')) {
  DOMPDF_autoload($class);
}
#4

[eluser]surfgatinho[/eluser]
There are instruction in the CI wiki somewhere. Try typing codeigniter dompdf integration into Google
I used this and it worked fine
#5

[eluser]MeanStudios[/eluser]
I'm having this same exact error and I'm not sure how to fix it.
I'm running CI in a local XAMPP environment.

@tOMky - Not sure where I would add that to try and make a fix.

Can someone please look into this?

I'm running CI 1.7.1
#6

[eluser]MeanStudios[/eluser]
Figured it out, just after the require_once line I put:
Code:
spl_autoload_register('DOMPDF_autoload');

Hope this helps others Smile.
#7

[eluser]mikkelz[/eluser]
Thanks MeanStudios - just encountered this error myself: CodeIgniter 2.0 + dompdf 0.5.2

Your solution works perfectly.
#8

[eluser]Unknown[/eluser]
dear mikkelz,
can you share the tips using dompdf using codeigniter 2.0

regards

cupu_coder
#9

[eluser]Unknown[/eluser]
Thank MeanStudios, your solution is working on me but i have problem that it tries to load native CI class too(ci_clasname.class.php). So refer to this post http://ellislab.com/forums/viewthread/112970/ i combine your solution to this.
in dompdf_config.inc.php:

# Do not autoload CodeIgniter classes.
if (strpos ($class, 'CI_') === false) {
$filename = mb_strtolower($class) . ".cls.php";
require_once(DOMPDF_INC_DIR . "/$filename");
}
}

dompdf_gen.php:
require_once APPPATH.'third_party/dompdf/dompdf_config.inc.php';
spl_autoload_register('DOMPDF_autoload');
$pdf = new DOMPDF();
$CI =& get_instance();
$CI->dompdf = $pdf;

FYI : i'm using codeigniter 2.1.3,HMVC,iamfiscus / Codeigniter-DOMPDF library(https://github.com/iamfiscus/Codeigniter-DOMPDF)

hope this will help someoneSmile




Theme © iAndrew 2016 - Forum software by © MyBB