php - How to Properly use HTML2PDF and Yii-PDF in Yii? -
hello i'm new yii don't know how use html2pdf & yii-pdf extension in yii pdf..
what want.. have page called http://localhost/site/users/results
.. showing list of users..so if click on user one, open new page called http://localhost/site/applicant/1
& user two, http://localhost/site/applicant/2
on these pages there information of users. want put download pdf button on page, if user clicks on it, able download information in pdf. there can many users. everyuser able download information in pdf.
i got html2pdf & yii-pdf .. got settings searching on google, unable find proper example use according requirements above.
config/main.php
'epdf' => array( 'class' => 'ext.yii-pdf.eyiipdf', 'params' => array( 'html2pdf' => array( 'librarysourcepath' => 'application.extensions.html2pdf.*', 'classfile' => 'html2pdf.class.php', // adding yii::$classmap /*'defaultparams' => array( // more info: http://wiki.spipu.net/doku.php?id=html2pdf:en:v4:accueil 'orientation' => 'p', // landscape or portrait orientation 'format' => 'a4', // format a4, a5, ... 'language' => 'en', // language: fr, en, ... 'unicode' => true, // true means clustering input text unicode (default = true) 'encoding' => 'utf-8', // charset encoding; default utf-8 'marges' => array(5, 5, 5, 8), // margins default, in order (left, top, right, bottom) )*/ ) ), ),
here controller.
class userscontroller extends controller { public function createpdf(){ $html2pdf = yii::app()->epdf->html2pdf(); $html2pdf->writehtml($this->renderpartial('index', array(), true)); $html2pdf->output(); } }
im totally new yii, how use extension, have never used extension before.. there other method download pdf of each user information. suggestions or , example of working code.
config/main.php
'epdf' => array( 'class' => 'ext.yii-pdf.eyiipdf', 'params' => array( 'html2pdf' => array( 'librarysourcepath' => 'application.vendors.html2pdf.*', 'classfile' => 'html2pdf.class.php', // adding yii::$classmap ) ), ),
controller
class userscontroller extends controller { public function createpdf(){ $pdffilename = 'test.pdf'; $html2pdf = yii::app()->epdf->html2pdf(); $html2pdf->writehtml($this->renderpartial('index', array(), true)); ob_clean(); $html2pdf->output($pdffilename,"i"); // output_to_browser /* output_to_browser = "i" */ /* output_to_download = "d" */ /* output_to_file = "f" */ /* output_to_string = "s" */ } }
Comments
Post a Comment