I got it working flawlessly a couple of days ago. Since plugins aren’t supported anymore, I converted it to helper, named dompdf_helper.php:
<?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", "landscape" );
$dompdf->render();
$dompdf->stream($filename . ".pdf");
}
?>
I’ve put the whole dompdf library to application/helpers/dompdf folder and I call it like this from controller:
function createpdf()
{
$this->load->helper('dompdf');
$this->load->helper('file');
$data['somedata']= $this->somemodel->somemethod();
$html = $this->load->view('pdf/view', $data, true);
pdf_create($html, 'somefilename');
}
This way I can format the view precisely the way I want. I’ve tried at least 5 pdf libraries, but this one is by far the most convenient to use.
I also want to post a link to super useful font making tool, which can help you make printouts in different charsets, for example farsi, central european… You do have to convert the data you’re passing to HTML Entity. For central european, that would mean a str_replace like this:
$in = array ('Č', 'č', 'Š', 'š', 'Ž', 'ž', 'Đ', 'đ', 'Ć', 'ć');
$out = array ('Č', 'č', 'Š', 'š', 'Ž', 'ž', 'Đ', 'đ', 'Ć', 'ć');
str_replace($in, $out, $variable)
I hope this helps someone.