Hi all, Yii newbie here!
I have a question about the following yii extension: http://www.yiiframework.com/extension/pdf/
I want to use the mpdf external library. According to the installation instructions I have to include the mpdf initialization code in the actionIndex.
This works fine, and a pdf is generated. However, I want to include the initialization code in a separate action in my SiteController and call this action from a view file through a link.
This is what I have so far, but I only get a blank page.
SiteController.php:
...
public function actionGeneratePdf()
{
# mPDF
$mPDF1 = Yii::app()->ePdf->mpdf();
# You can easily override default constructor's params
# $mPDF1 = Yii::app()->ePdf->mpdf('', 'A5');
# render (full page)
$mPDF1->WriteHTML($this->render('index', array(), true));
# Load a stylesheet
$stylesheet = file_get_contents(Yii::getPathOfAlias('webroot.css') . '/main.css');
$mPDF1->WriteHTML($stylesheet, 1);
# renderPartial (only 'view' of current controller)
# $mPDF1->WriteHTML($this->renderPartial('index', array(), true));
# Renders image
# $mPDF1->WriteHTML(CHtml::image(Yii::getPathOfAlias('webroot.css') . '/bg.gif' ));
# Outputs ready PDF
$mPDF1->Output();
}
...
View file:
<?php echo CHtml::link('Generate PDF',array('site/GeneratePdf')); ?>