class Pdf {
public function pdf_create($html, $filename, $paper, $orientation)
{
require_once("dompdf/dompdf_config.inc.php");
spl_autoload_register('DOMPDF_autoload');
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->set_paper($paper,$orientation);
$dompdf->render();
$dompdf->stream($filename.".pdf");
}
}
then when you wanna create pdf put this in controller (for example):
public function actionPrint($id)
{
Yii::import('ext.Pdf',true);
$model = $this->loadModel($id);
$this->pdf = new Pdf();
$html = $this->renderPartial('_print', array('model'=>$model), true, true);
$this->pdf->pdf_create($html, '{name of pdf file}', 'a4', 'portrait');
}