Welcome Guest, Not a member yet? Register   Sign In
DomPDF Broken
#1

[eluser]mdavis1982[/eluser]
Hi all...

I was using DomPDF whilst developing a site for a client and it was working wonderfully with all my test data... However, now that I have the real data in (there's much more of it - 3252 records) it's stopped working. I'm also using the ActiveRecord class from the Wiki.

Here's the code from my controller function:
Code:
function generateCatalogue()
{
    $this->load->model('artist');
    $this->db->orderby('sort_name', 'ASC');
    $allArtists = $this->artist->find(ALL);
            
    foreach($allArtists as $artist)
    {
        $artist->fetch_related_tracks('track', 'ORDER BY tracks.sort_title ASC');
                
        foreach($artist->tracks as $track)
        {
            $newTrack = $this->track->find_by_id($track->id);
            $newTrack->fetch_related_artists();
            $newTrack->fetch_related_trackversions();
                    
            $data['tracks'][] = $newTrack;
            $newTrack = NULL;
        }
                
        $artist = NULL;
    }
            
            
    $this->load->plugin('to_pdf');            
    $html = $this->load->view('catalogue/catalogue', $data, true);

    $this->load->helper('file');
    pdf_create($html, 'catalogue.pdf', $this->config->item('mbt_catalogue_path'), FALSE);
}

And in my to_pdf_pi.php file:
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

function pdf_create($html, $filename, $path = '', $stream = TRUE)
{
    require_once('dompdf/dompdf_config.inc.php');
    
    $dompdf = new DOMPDF();
    $dompdf->set_paper('a4');
    $dompdf->load_html($html);
    $dompdf->render();
    
    if ($stream)
    {
        $dompdf->stream($filename);
    }
    else
    {
    if (file_exists($path . $filename))
    {
        unlink($path . $filename);
    }
            
        write_file($path . $filename, $dompdf->output());
    }
}

?>

If I echo out the $html in my controller I get all the data presented on the screen, but when trying to create the PDF I get the error:
Quote:Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 6291456 bytes) in /Users/matt/Sites/mbtadmin/system/plugins/dompdf/include/frame_tree.cls.php on line 169

I've tried changing my memory limit in php.ini up to 512mb, but still get the same kinds of errors (and this wouldn't be practical on the hosting for the client's site anyway). If anyone could help me fix this error I would be most appreciative!

Thanks guys...

Matt


Messages In This Thread
DomPDF Broken - by El Forum - 02-15-2008, 04:38 PM
DomPDF Broken - by El Forum - 02-15-2008, 04:52 PM
DomPDF Broken - by El Forum - 05-26-2008, 04:42 AM
DomPDF Broken - by El Forum - 05-07-2011, 10:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB