Yii Framework Forum: Mpdf Header - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Mpdf Header Rate Topic: -----

#1 User is offline   giorg 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 04-June 13

Posted 13 June 2013 - 06:10 AM

Hi everybody,

I successfully created a pdf report this way:

$mPDF1 = Yii::app()->ePdf->mpdf();
$mPDF1->WriteHTML($this->render('report', array('test'=>$test), true));
$mPDF1->Output();

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
0

#2 User is offline   mirunho 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 19-December 12
  • Location:Gdansk, Poland

Posted 17 June 2013 - 01:20 AM

Hi,
Did You try ?
$mPDF1->SetHeader($myhtml);
0

#3 User is offline   JFReyes 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 503
  • Joined: 28-October 09
  • Location:Puerto Rico

Posted 11 July 2013 - 10:12 AM

View Postmirunho, on 17 June 2013 - 01:20 AM, said:

Hi,
Did You try ?
$mPDF1->SetHeader($myhtml);


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?

Thanks,
José
0

#4 User is offline   JFReyes 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 503
  • Joined: 28-October 09
  • Location:Puerto Rico

Posted 25 September 2013 - 10:27 AM

View PostJFReyes, on 11 July 2013 - 10:12 AM, said:

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?

Thanks,


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.
José
0

#5 User is offline   Juan Antonio 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 16-August 12

Posted 22 October 2013 - 05:49 PM

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

$mPDF1 = Yii::app()->ePdf->mpdf();
$this->layout='//layouts/SalesReport';
$mPDF1->WriteHTML($this->render('sales',array('model'=>$model),true));
$mPDF1->Output('pdfName','D');
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users