Browsers: How to Make Firefox Open PDFs

8365309904810981093

TLDR:

In Firefox: 
  1. Enter "about:config" into the address bar.
  2. Click past the warranty warning.
  3. Search for the preference "pdfjs.disabled" and make sure it's set to "false". 
  4. Enter "about:preferences#applications" into the address bar. 
  5. Search for the Content Type of either "PDF", "Portal Document File (PDF)", or "Adobe Acrobat Document" and set the Action value to "Preview in Firefox". 

The Setting...

This week at work, we got a couple of customer complaints about Firefox not opening PDF's on one of our web pages. The way we had the PDF open up was using an <iframe> element and setting the URL of the iframe to the source of the PDF. It worked fine in Chrome and IE11 (which are the other two major browsers we support) so what happened? I'd say the perfect storm.

The Leaking Boat: Firefox Ending Support for NPAPI Plugins

Back in October 2015, the Mozilla Firefox team announced that they were deprecating browser NPAPI plugins. This is relevant to PDF's because in the past, if you had Adobe Acrobat Reader (or one of their desktop PDF readers), you can choose to make the browser use Adobe Acrobat's browser plugin. And you can tell the browser, "Yes I want to default to using the browser plugin and never prompt me again." Slowly, water was leaking into this old outdated boat of ours. But it was so slow and we had other more urgent problems to deal so we didn't even notice.

It wasn't until March of this year, they officially ended all support for browser plugins with the release of Firefox 52 (first release note item in the "changed" section). When users upgraded their Firefox, they would no longer be able to use their Adobe Acrobat plugin (though this was only applicable for 32-bit version and 64-bit version had already done that awhile back). The issue was Firefox's code made it so if the user chose to use a browser plugin for PDF's, their default PDF viewer would also get disabled (see code here). Come upgrade time, the default PDF viewer wasn't re-enabled and browser plugins support was dropped. Then the user couldn't open PDF's in their Firefox browser.

The good thing was we had many users from large companies and schools and institutions who were using Firefox Extended Support Release (ESR). And Firefox ESR still has NPAPI plugin support (at least until 2018) so no alarms were going off between March and now. I bet there were users who experienced this defect but didn't bother reporting it because they still got their PDF, albeit in Adobe Acrobat desktop app.

Unfavorable Waters: Adobe Acrobat Reader Being Outdated

But the sea.. she was not in our favor. Recently, Adobe Acrobat Reader (and their other desktop PDF Readers) and the browser plugin which came along with them must have been deemed too outdated for Firefox ESR. We started getting reports bubbling up through our customer service team that Firefox users couldn't see PDF's on that page. Instead, the PDF files were getting downloaded and saved to their downloads folder. 

My Google-Fu led me down the deep depths of the waters. After playing with Firefox's secret preferences and guessing-and-checking, I was able to find three-too-many ways to upgrade your Adobe Acrobat Reader on Windows machines. The most foolproof and surefire was to: 
  1. Download Adobe Labs' AcroCleaner Tool.
  2. Use it to uninstall any Adobe PDF reader programs you have.
  3. Then get a new Adobe Acrobat Reader installer from https://get.adobe.com/reader/.
  4. Run through the installer and if Davey Jones favored thee, ye' should 'ave the latest Adobe Acrobat Reader. 
With the latest Adobe Acrobat Reader, users with Firefox ESR are able to use their Adobe Acrobat browser plugin to view PDF's in Firefox. One just has to make sure certain preferences are set properly..
  1. Enter "about:config" into the address bar.
  2. Search for the preference "plugin.disable_full_page_plugin_for_types". 
  3. If that preference is there, make sure it has the substring "application/pdf" in its value. If the preference is not there, then add a new row to the preferences with key "plugin.disable_full_page_plugin_for_types" and value "application/pdf".
  4. Enter "about:addons" into the address bar.
  5. Look for "Adobe Acrobat" or "Adobe Acrobat Reader DC" and change the select dropdown to be "Always Activate".
  6. Enter "about:preferences#applications" into the address bar. 
  7. Search for the Content Type of either "PDF", "Portal Document File (PDF)",  or "Adobe Acrobat Document" and set the Action value to "Use Adobe Acrobat (in Firefox)". 
Ahoy matey! After following the steps above, Firefox ESR is able to open PDFs. The caveat is the user must use the ESR version, which most regular people wouldn't do. There is also a security concern here. With Adobe Acrobat's browser plugins, the desktop apps have to be constantly updated, in case they put out some security patch. Otherwise, you might find yourself the victim of a hack.

Clear Seas Ahead: Using Firefox's Built-In PDF Viewer

Google searching for "opening PDF's in Firefox", I found a lot of the same answers. It's most either going to "about:preferences#application" to change the option for PDF's to "Preview in Firefox" or removing "plugin.disable_full_page_plugin_for_types" to use Adobe Acrobat Reader plugin. But I couldn't even see "Preview in Firefox" AND Firefox just dropped support for those plugins!

Fortunately, after spending the better half of an afternoon, my Google-Fu came through and I found one Firefox help forum post with a link to the code that controlled all this. And I found out there was a-whole-nother set of secret preferences to enable/disable the browser's built-in PDF viewer, which uses PDF.js. The magic preference I needed was "pdfjs.disabled" under the page "about:config". Users of browser plugins for PDF's will find this preference set to "true". This, in turn, made it so the user couldn't ever see or select "Preview in Firefox" under the page "about:preferences#application" to use the built-in PDF viewer. 

Again, the real solution on Firefox 52+ and Firefox ESR 52 is to:
  1. Enter "about:config" into the address bar.
  2. Click past the warranty warning.
  3. Search for the preference "pdfjs.disabled" and make sure it's set to "false". 
  4. Enter "about:preferences#applications" into the address bar. 
  5. Search for the Content Type of either "PDF", "Portal Document File (PDF)", or "Adobe Acrobat Document" and set the Action value to "Preview in Firefox". 
It took me most of the day to come to this solution. Hopefully this saved you from a day of fumbling around with Firefox and Adobe Acrobat Reader. Enjoy your (hopefully) future-proof PDF viewing experience in Firefox. 

Comments

Popular posts from this blog

Angular (2+): Core vs Shared Modules

Home Improvement: How to Make Your Toilet Flush Stronger.. Without Opening Toilet Tank

Food: How Carrot-Coconut Sunny-Side-Up Egg is Made