Mpdf Header

Hi everybody,

I successfully created a pdf report this way:

$mPDF1 = Yii::app()->ePdf->mpdf();

$mPDF1->WriteHTML($this->render(‘report’, array(‘test’=>$test), true));


and then then necessary html code in the report template. Now they ask me to set a header, a bunch of html to be reported in every page. I saw in the official mPDF doc there is a method named mPDF1->SetHTMLHeader($myhtml), but when I try to do that I receive just the pdf without any of $myhtml.

any suggestion?

thanks a lot


Did You try ?


I have the same problem and tried both SetHTMLHeader and SetHeader (and other mPDF commands as well) but they don’t work with the render() method. If you WriteHTML any regular text they work fine. Any ideas?


I found out that a view layout overrides most mPDF commands, so render() can’t be used but renderPartial() can since it doesn’t use a layout. The downside is that it requires mode code to “beautify” the report using mPDF functions and limited CSS/HTML attributes.

I just applied a layout with the content I wanted to appear in header and footer:

$mPDF1 = Yii::app()->ePdf->mpdf();




Try true in the 3º parameter.

$mPDF1->SetHTMLHeader($this->renderPartial('/site/_header', null, true));