Export to PDF using tcpdf

Dears,

I was using the easiest example for using tcpdf as following

<?php

Yii::import(‘ext.tcpdf.tcpdf’);

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

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

$pdf->SetCreator(PDF_CREATOR);

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

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

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

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

$pdf->setPrintHeader(false);

$pdf->setPrintFooter(false);

$pdf->AliasNbPages();

$pdf->AddPage();

$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-’.

Local\EWHy#)5#{!5

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