Change Header Type

Hi

I’m very new to Yii. I want display the content of the pdf on the browser. I put this piece of code inside view.

header(‘Content-Type: application/pdf’);

header(‘Content-Disposition: inline; filename=“foo.pdf”’);

but it gave me an error. "Cannot modify header information – headers already sent".

I wonder if I can change the header type to display pdf?

Thanks

You should send the headers from the controllers before echoing / rendering anything else.

Thanks! that works!