Export to PDF using tcpdf


I was using the easiest example for using tcpdf as following



$pdf = Yii::createComponent(‘application.extensions.tcpdf.tcpdf’,

                        'P', 'mm', 'A4', true, 'UTF-8',true,false);


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

$pdf->SetTitle("TCPDF Example 002");

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

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





$pdf->SetFont("times", "BI", 20);

$pdf->Cell(0,10,“Example 002”,1,1,‘C’);

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


But I got the following message

File does not being with ‘%PDF-’.


I’ve searched a lot but with no hope, have any ideas?

Do not put your pdf generation code in a view, but rather use it in a controller