PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, March 19, 2022

[FIXED] Yii, Php, mPDF, generating a pdf with widgets of different orientations

 March 19, 2022     mpdf, pdf, php, yii     No comments   

Issue

I am implementing an application in Yii php, and I am trying to make PDFs using the mPDF extension.

I'm generating a sort of Summary Report where I make a pdf for it. Inside the generated pdf are 3 widgets, basically tables to create that report.

Here's how it looks:

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

$mPDF1 = Yii::app()->ePdf->mpdf('', 'A5');
..
..//set mpdf properties etc..

$mPDF1->WriteHTML($stylesheet, 1);

$mPDF1->WriteHTML($html1,2);
//say $html1 is a widget/table  with a portrait orientation

$mPDF1->WriteHTML($html2,2);
//$html2 is a widget/table with a portrait orientation

$mPDF1->WriteHTML(&html3,2);
//$html3 is a widget/table that needs to have a landscape orientation because it's too long.

//and then output the pdf and so on..

Above code works, but displays the tables all in a portrait orientation, I need to display the table in $html3 in a landscape orientation. Is there a way to do this?mpdF properties I guess or something. And also, is is there a way to separate $html3 and have it on the start of the next page in the same PDF?


Solution

Try to AddPage with Landscape orientation:

$mPDF1->WriteHTML($html2,2);
//$html2 is a widget/table with a portrait orientation

$mPDF1->AddPage('L');
$mPDF1->WriteHTML(&html3,2);


Answered By - Sergey
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing