MaxQ
MaxQ

Reputation: 605

Problems using dompdf and codeigniter

I have started experimenting with codeigniter and pdfs. I'm using the latest version of both. For some reason, i'm getting this error when trying to render the pdfs:

Warning: require_once(C:\Users\Manfred\Dropbox\Web\Alodu\application\helpers\dompdf/include/ci_exceptions.cls.php) [function.require-once]: failed to open stream: No such file or directory in C:\Users\Manfred\Dropbox\Web\Alodu\application\helpers\dompdf\dompdf_config.inc.php on line 208

Fatal error: require_once() [function.require]: Failed opening required 'C:\Users\Manfred\Dropbox\Web\Alodu\application\helpers\dompdf/include/ci_exceptions.cls.php' (include_path='.;C:\php\pear') in C:\Users\Manfred\Dropbox\Web\Alodu\application\helpers\dompdf\dompdf_config.inc.php on line 208

Code used is:

function pdf()
    {
         $this->load->helper(array('dompdf', 'file'));
         // page info here, db calls, etc.     

         /*
         $data=array(
         "$title"=>"Hello!",
         "$test_questions"=>"1,2,3,4",
         );
         */

        $data['test_questions']= "hello";


         $html = $this->load->view('pdf/test_ibdp', $data, true);

         $filename="Test".$data['test_questions'];

         pdf_create($html, $filename);
         write_file('name', $data);

    }   

And the helper:

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
function pdf_create($html, $filename, $stream=TRUE) 
{
    require_once("dompdf/dompdf_config.inc.php");

    $dompdf = new DOMPDF();
    $dompdf->load_html($html);
    $dompdf->set_paper("a4", "portrait" );
    $dompdf->render();
    $dompdf->stream($filename . ".pdf");
}
?>  

and the view (pure HTML)

<html>
<head>
<title>Hello!</title>
</head>
<body>
    <h1>HelloAgain</h1>
</body>
</html>

Any suggestions? I'm not that experienced in PHP and i'm quite confused. I just re-downloaded the library, i've tried keeping it really simple by stripping away extras in my code. Nothing seems to work. any help would be great :)

Upvotes: 0

Views: 10171

Answers (4)

Fabien M&#233;nager
Fabien M&#233;nager

Reputation: 140205

This is a class autoloader issue. Which version of DOMPDF do you use? I think dompdf 0.5 had a problem when integrated inside a framework like CI. The 0.6 version doesn't have this probleme anymore, and if the problem persists, write

define("DOMPDF_AUTOLOAD_PREPEND", true)

in dompdf_config.custom.inc.php.

Upvotes: 5

Adam
Adam

Reputation: 1694

Correct the dompdf file path. Also remove this line of code:

write_file('name', $data);

The following line is enough:

pdf_create($html, $filename);

Upvotes: 0

Karo
Karo

Reputation: 744

Path to the file is incorrect.

C:\Users\Manfred\Dropbox\Web\Alodu\application\helpers\dompdf/include/ci_exceptions.cls.php

You can use DIRECTORY_SEPARATOR.

Upvotes: 0

Paul Dessert
Paul Dessert

Reputation: 6389

The error is saying the path below is not correct. Recheck the path

require_once("dompdf/dompdf_config.inc.php");

Upvotes: 0

Related Questions