Welcome Guest, Not a member yet? Register   Sign In
Trying to export PDF [Blank Page]
#1

[eluser]Unknown[/eluser]
HI,

I'm new to CodeIgniter and I'm just trying to generate a PDF document from a view. I'm using DOMPdf as described in this link but once I run the controller, a blank page appears. It just seems to work when I reduce all the view's HTML to something like "<h1>TEST</h1>"...

I guess it is a memory_limit issue, but even upgrading it to 96 or 128MB (even in localhost) it doesn't work.

Can anyone help me?

This is my code:

CONTROLLER:
Code:
&lt;?php

class Site extends Controller {
    
    function pdf()
    {
        $this->load->plugin('to_pdf');              
         $this->load->library('table');
        
        $data['table'] = $this->db->query("SELECT user,name,emal FROM `table`");

         $html = $this->load->view('table',$data);    
        pdf_create($html, 'filename');
    
    }  
    
}

VIEW:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
&lt;title&gt;&lt;/title>
&lt;/head&gt;
&lt;body&gt;
    <h1>Table</h1>
    &lt;?
        $tmpl = array (
            'table_open'          => '<table border="0" cellpadding="4" cellspacing="0" id="example">',
            'heading_row_start'   => '<thead><tr>',
            'heading_row_end'     => '</tr></thead>',
            'table_close'         => '</table>'
        );
        
        $this->table->set_template($tmpl);
        $this->table->set_heading('User', 'Name', 'E-mail');
        
        echo $this->table->generate($table);  
    ?&gt;    
&lt;/body&gt;
&lt;/html&gt;
#2

[eluser]Unknown[/eluser]
Anyone can help?

Thanks!
#3

[eluser]pegas[/eluser]
Structure the source code as a helper and not a plugin and it will work. Just rename the to_pdf_pi.php file to to_pdf_helper.php and move the sources, and that's it Smile
#4

[eluser]Amitabh Roy[/eluser]
Generating pdf with dompdf has its own set of woes.

If you are getting blank pages , you may need to comment the

extension=php_pdf.dll in php.ini and restart apache and then again try to generate the pdf.



Check this post on bambooinvoice forum , on which I posted a solution around 3 years ago.

Bamboo invoice forum - pdf generation fails using dompdf
#5

[eluser]CroNiX[/eluser]
In order to get the view as a variable you need to set the 3rd parameter to TRUE.
$html = $this->load->view('table',$data, TRUE);
Otherwise it outputs directly to the browser.
http://ellislab.com/codeigniter/user-gui...oader.html




Theme © iAndrew 2016 - Forum software by © MyBB