PDF and Firefox

Trigger Hippie

Senior Member.
Hi Mick,

FYI, I'm having problems automatically opening PDF files. This is specific to Metabunk. It might be a server side issue where the PDF file type is not specified correctly.

This is the box that keeps poping up every time I click a PDF link on Metabunk. Note, Firefox doesn't recognize the PDF file and the "Do this automatically... " box is greyed out.

0.png


This is what I found on the Firefox support site. HTH.

00.png
http://support.mozilla.org/en-US/kb/change-firefox-behavior-when-open-file
 
Hi Mick,

FYI, I'm having problems automatically opening PDF files. This is specific to Metabunk. It might be a server side issue where the PDF file type is not specified correctly.

This is the box that keeps poping up every time I click a PDF link on Metabunk. Note, Firefox doesn't recognize the PDF file and the "Do this automatically... " box is greyed out.

0.png


This is what I found on the Firefox support site. HTH.

00.png
http://support.mozilla.org/en-US/kb/change-firefox-behavior-when-open-file
pdfdialog.png

I tried to reproduce the issue, but I'm getting the correct behavior with Firefox v 25.01 on Windows 7. What OS are you using? My Windows 8 machine is currently offline but I plan to fire it up later today after a little maintenance.

Edit: have you tried scrolling through the options in the dropdown? Is Adobe Reader available as an option? What the heck is Evince, anyway.
 

Attachments

  • test_nums-9 bytes.txt
    9 bytes · Views: 536
Last edited:
I patched the XF code to fix it.

Code:
class XenForo_ViewPublic_Attachment_View extends XenForo_ViewPublic_Base
{
    public function renderRaw()
    {
        $attachment = $this->_params['attachment'];

        $extension = XenForo_Helper_File::getFileExtension($attachment['filename']);
        $imageTypes = array(
            'gif' => 'image/gif',
            'jpg' => 'image/jpeg',
            'jpeg' => 'image/jpeg',
            'jpe' => 'image/jpeg',
            'png' => 'image/png',
            'pdf' => 'application/pdf',
        );

        if (in_array($extension, array_keys($imageTypes)))
        {
            $this->_response->setHeader('Content-type', $imageTypes[$extension], true);
            $this->setDownloadFileName($attachment['filename'], true);
        }
        else
        {
            $this->_response->setHeader('Content-type', 'application/octet-stream', true);
            $this->setDownloadFileName($attachment['filename']);
        }

        $this->_response->setHeader('ETag', $attachment['attach_date'], true);
        $this->_response->setHeader('Content-Length', $attachment['file_size'], true);
        $this->_response->setHeader('X-Content-Type-Options', 'nosniff');

        return new XenForo_FileOutput($this->_params['attachmentFile']);
    }
}

just added the pdf line
 
Last edited:
Fixed, thanks. Those extra mouse clicks I was being forced into were giving me carpal tunnel.:)

@Mark Barrington I'm using Ubuntu 12.04 LTS (The worlds most popular free OS) with Firefox 26.
I've only used Ubuntu through a terminal, so I'm not familiar with how the desktop looks. Most of my experience is with Windows, which ignores the mime type in the header if it recognizes the extension. Which isn't always a good thing.
 
All Linux desktops are very customizable via the many windows managers and themes. If you're into eyecandy there's Compiz Fusion.

I made the final full switch from Windows about six years ago for no other reason than I was building my own PC and didn't want to pay for an OS. I've still got a little nettop PC with Win7 that is mostly used for iTunes and occasionally updating my phone and GPS firmware.
 
Back
Top