Generate PDF via tcpdf in Yii

Hi! I have CGridView to generate PDF. In this CGridView I have column with CCheckBox to choose which notes to generate. But now it generates everytime only first note (when I dont’t even chose it). Can anyone help me - how to generate in PDF-file only selected rows? This is my action, below:

public function actionCreatePdf()



        $pdf = Yii::createComponent('application.extensions.tcpdf.ETcPdf', 'L', 'cm', 'A5', true, 'UTF-8');


        $pdf->SetAuthor("Nicola Asuni");

        $pdf->SetTitle("PDF document");

        $pdf->SetSubject("TCPDF Tutorial");

        $pdf->SetKeywords("TCPDF, PDF, example, test, guide");




        $pdf->SetFont('dejavusans', " ", 17);

        $tbl = "PDF document" . "<br><br>"; //. date('d.m.Y', time()) . "<br><br>";

        $tbl .= '<tbody> <li><b>User</b>:';

        $tbl .= "{$model->user->fullname}";

        $tbl .= '</li>';

        $tbl .= '<p>';

        $tbl .= '<tbody> <li><b>Department</b>:';

        $tbl .= "{$model->deps->department}";

        $tbl .= '</li>';

        $tbl .= '<p>';

        $tbl .= '<tbody> <li><b>Staff</b>:';

        $tbl .= "{$model->staff->fullname}";

        $tbl .= '</li>';

        $tbl .= '<p>';

        $tbl .= '<tbody> <li><b>Date</b>:';

        $tbl .= "{$model->meetdate}";

        $tbl .= '</li>';

        $tbl .= '<p>';

        $tbl .= '<tbody> <li><b>Time</b>:';

        $tbl .= "{$model->meettime}";

        $tbl .= '</li>';

        $tbl .= '<p>';

        $tbl .= '<tbody> <li><b>Office</b>:';

        $tbl .= "{$model->office_num}";

        $tbl .= '</li>';

        $tbl .='</tbody>';

        $pdf->writeHTML($tbl, true, true, false, false, '');

        $pdf->Output("example_002.pdf", "I");



Each row of CGridView have an id.

In CgridView we have :

  • $row the row number (zero-based)
  • $data the data model for the row
  • $this the grid view object

so you can do a loop to know if a row have her checkbox selected or not ! :)

CGridView doc :

Ps : sorry for my english I’m trying to improve it :)

Thx. I’ve read API on your link, but I still don’t get it honestly.

It would be better to see some example, unnecessarily with my action, maybe even with delete action or whatever.

PS: It’s ok. My English also not perfect.

Can anyone offer different way to solve this problem? I thinking about make array of checked rows. Am I on right way? really need help. :mellow:

I used FPDF with yii successfully in the past. It enables us to create pdf