Setting to automatically 'Save File' for PDFs is stored in handlers.json instead of prefs.js
I have tried to set various prefs.js values to tell a clean install of Firefox 57.0.3 to automatically handle applications with .pdf by "Save File".
After some digging, I found that changing the setting Menu>Options>Applications- Content Type|"Portable Document Format (PDF)" Action|"Save FIle" only makes a difference in the profile found in %APPDATA%/Roaming/Mozilla/Firefox/Profiles/abcdef12.default by changing the some values in "handlers.json". I expected the change to be stored in "prefs.js".
The value in question is:
Is there a way to store this change in the handlers.json file in prefs.js?
A few like: browser.helperApps.alwaysAsk.force = false browser.helperApps.neverAsk.saveToDisk = application/pdf
seem to be important, but they don't do it. I have set several other preferences such as the download directory and the setting to use it. I have tried dozens of others, but after recording the profile and changing just that setting, then getting the difference in the profile I found that prefs.js is not changed at all so I gave up looking.
Modified by ccraig
Additional System Details
- User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36
You can check out the comments in this file:
Hmm, I'm not an expert on my Firefox history but I'm fairly certain this isn't true and at the very least it's not reasonably stated.
First of all, before Firefox 48 I know that without touching handlers.json I was able to set the default action for opening a .pdf file, such that any pdf would automatically download to my downloads folder without asking the first time. I'm 99% certain that it was a setting stored in prefs.js. I'm also pretty sure that the 2 preferences I listed in the original question are all that need to be set for Firefox to understand what I want to happen when I click a link that contains something tagged with "content-type" "application/pdf".
browser.helperApps.alwaysAsk.force = false - Don't always ask what to do with files
browser.helperApps.neverAsk.saveToDisk = application/pdf - If the content-type is application/pdf then never ask me what to do and just use save to disk.
So we've told Firefox it doesn't need to always launch the helper app that pops up when you click a download, and if it's a pdf, don't ask and save it to disk. Why would Firefox still be asking? Well, it seems like the handler has one more thing. It has settings for something with a mimeType application/pdf. The setting that seems to be needed is the "action:0". There is already a preference "pdfjs.previousHandler.preferredAction" and it takes an integer value (seems like 0-4). So telling me there can't be another "defaultHandler.pdf.action" that can be set to 0 is a little odd.
"Firefox would only download PDF files automatically when the builtin PDF Viewer is disabled..."
I set the pdfjs.disabled preference to true and was able to get the file to download automatically. Thank you for pointing that out. I still think the values I set before should be enough to handle the PDF. Apparently, the builtin PDF Viewer gets to say whether or not it wants to handle a PDF before the other preferences are taken into account. Whether this is intended or not is really not an issue to me anymore.
Thank you for your assistance.
For clarity if anyone finds this when trying to get PDFs to download automatically using prefs.js:
Setting 'browser.helperApps.alwaysAsk.force = false' & 'browser.helperApps.neverAsk.saveToDisk = application/pdf' as well as the browser.download.* preferences does not force a download to occur, you must also tell Firefox not to use pdfjs ('pdfjs.disabled=true'). 'plugin.state.nppdf'=0 does not do this, neither does "plugin.disable_full_page_plugin_for_types='application/pdf'".