[eluser]Solarpitch[/eluser]
Hi Guys,
I've been reading through all posts and cant find a possible solution to this. Everytime a PDF is generated it is corrupt and cant be read by Adobe Reader. This is what I have...
Controller ...
Code:
class Invoice extends Controller{
function Invoice()
{
parent::Controller();
}
function index()
{
$data['title'] = 'Some title';
$data['heading'] = 'Some Head';
$this->load->helper('file');
$this->load->plugin('to_pdf');
$html = $this->load->view('pdf/invoice', $data, true);
pdf_create($html, 'Test',FALSE);
}
}
to_pdf_pi.php
Code:
if (!defined('BASEPATH')) exit('No direct script access allowed');
function pdf_create($html, $filename)
{
require_once('dompdf/dompdf_config.inc.php');
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream($filename.'.pdf');
}
view
Code:
<body>
<h3><?=$title;?></h3>
<p><?=$heading;?></p>
</body>
</html>
I have the dompdf directory inside my plugins folder also. The PDF generation seems to work outside of the framework but just not when I try to adapt it this this approach for Codeigniter.
Any help would be great as I have a tight deadline for a project that needs a PDF feature
.
Thanks.