I'm creating a Joomla component and among the sights must render itself as PDF. Within the view, I've attempted setting this content-type using the following line, however when I begin to see the response, it's text/html anyways.

header('Content-type: application/pdf')

Basically do that inside a regular php page, everything works not surprisingly. It appears that I have to tell Joomla to make use of application/pdf rather than text/html. How do i get it done?

Note: Setting other headers, for example Content-Disposition, works not surprisingly.

Since version 1.5 Joomla has got the JDocument object. Use JDocument::setMimeEncoding() to create this content type.

$doc =&lifier JFactory::getDocument()


Inside your special situation, a glance at JDocumentPDF might be worthwile.

For individuals individuals convinced that the above mentioned is an extremely old answer, I make sure the JDocument::setMimeEncoding() still works, on the 1.6 version (haven't attempted it on 1.7 yet).