Yii Framework Forum: DOMPDF Help - Yii Framework Forum

Jump to content

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

DOMPDF Help PDF Generation using DOM PDF Rate Topic: -----

#1 User is offline   undefinable 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 01-February 11

Posted 15 August 2011 - 05:04 PM

Hi,

Need help using DOMPDF for PDF generation, stuck real bad.


Tried using the class from here : http://www.yiiframew..._pdf#entry36748


Not getting any popups and no PDF getting generated anywhere.

Can anyone help me going about including this class withing Yii Framework.

Thanks
0

#2 User is offline   Firgilius 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 17-August 11

Posted 17 August 2011 - 11:51 AM

Put dompdf in extensions and try this

class Pdf {

    public function pdf_create($html, $filename, $paper, $orientation)
    {
        require_once("dompdf/dompdf_config.inc.php");
        spl_autoload_register('DOMPDF_autoload');

        $dompdf = new DOMPDF();
        $dompdf->load_html($html);
        $dompdf->set_paper($paper,$orientation);
        $dompdf->render();        
        $dompdf->stream($filename.".pdf");        
    }
}


then when you wanna create pdf put this in controller (for example):

public function actionPrint($id)
        {
            Yii::import('ext.Pdf',true);
            $model = $this->loadModel($id);
            $this->pdf = new Pdf();
            $html = $this->renderPartial('_print', array('model'=>$model), true, true);
            $this->pdf->pdf_create($html, '{name of pdf file}', 'a4', 'portrait');
        }

2

#3 User is offline   undefinable 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 01-February 11

Posted 18 August 2011 - 12:53 AM

Thanks a ton dude. Works like a charm.
0

#4 User is offline   Firgilius 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 17-August 11

Posted 19 August 2011 - 03:50 PM

you're welcome :)
0

#5 User is offline   radames_ 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 73
  • Joined: 06-October 11
  • Location:São Paulo - Brazil

Posted 04 June 2012 - 09:43 AM

hi,


Yii::import('ext.Pdf',true);


what it means ... ???
Radamés Galvao
PHP with Yii devel.
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