Reputation: 12469
I am developing a Joomla component and one of the views needs to render itself as PDF. In the view, I have tried setting the content-type with the following line, but when I see the response, it is text/html anyways.
header('Content-type: application/pdf');
If I do this in a regular php page, everything works as expected. It seems that I need to tell Joomla to use application/pdf instead of text/html. How can I do it?
Note: Setting other headers, such as Content-Disposition
, works as expected.
Upvotes: 6
Views: 8521
Reputation: 1
I had the same problem in joomla 2.5. After 8 hours of clicking around in the joomla admin panel I found a solution.
You should now be able to load pdfs into media manager. Hope this works for you. I just set mine up to upload .mov
extensions.
The problem is it only worked once. Now the browse link doesn't work whenever I navigate to a movie .mov file on my hard drive. But it does if I select any other file type ?
Upvotes: 0
Reputation: 4271
For those of you thinking that the above is a very old answer, I confirm that the JDocument::setMimeEncoding() still works, even on the 1.6 version (haven't tried it on 1.7 yet).
Upvotes: 1
Reputation: 338416
Since version 1.5 Joomla has the JDocument object. Use JDocument::setMimeEncoding() to set the content type.
$doc =& JFactory::getDocument();
$doc->setMimeEncoding('application/pdf');
In your special case, a look at JDocumentPDF may be worthwile.
Upvotes: 12