Hi…i want to make a report PDF using DOMPDF.i read from this articel and i follow it.
in dompdf_config.inc.php :
function DOMPDF_autoload($class)
{
$filename = mb_strtolower($class) . ".cls.php";
if(file_exists(DOMPDF_INC_DIR . "/$filename")) {
require_once(DOMPDF_INC_DIR . "/$filename");
}
}
in extension/yiidompdf/yiidompdf.php :
<?php
/**
* Yii DOMPDF
* ---------------------------------------------
*
* @author dida nurwanda (dida_n@ymail.com)
* @blog didanurwanda.blogspot.com
*/
require_once dirname(__FILE__).'/dompdf_config.inc.php';
Yii::registerAutoloader('DOMPDF_autoload');
class yiidompdf extends CApplicationComponent
{
public $dompdf;
public function init()
{
if($this->dompdf===null)
$this->dompdf= new DOMPDF();
return $this->dompdf;
}
public function generate($file, $filename='', $download=false)
{
$this->dompdf->load_html($file);
$this->dompdf->render();
$this->dompdf->stream($filename,array('Attachment'=>$download));
}
}
config/main.php :
..
'dompdf'=>array(
'class'=>'ext.yiidompdf.yiidompdf'
),
..
in controller:
public function actionPDF()
{
$pdf=Yii::app()->dompdf;
$pdf->dompdf->set_paper('a5');
$pdf->generate($this->renderPartial('admin',true,true),'laporan.pdf',false);
}
but display a warning "undefined model"…so i try to modify like this :
public function actionPDF()
{
$model=new Naskah('search');
$pdf=Yii::app()->dompdf;
$pdf->dompdf->set_paper('a5');
$pdf->generate($this->render('admin',array(
'model'=>$model,),true,true),'laporan.pdf',false);
}
but the next warning "Function set_magic_quotes_runtime() is deprecated"
can anyone help me how to solve this?