2023-08-01
Turning off the sidebar of Firefox's built in PDF viewer
Over on the Fediverse, I said:
Firefox tip: do you hate that the built-in PDF viewer opens the space-eating sidebar all the time (I do)? If so, go to about:config and set pdfjs.sidebarViewOnLoad to '0' from its default. As far as I know this is not exposed as a Preferences setting, so you have to use about:config (and search the magic numbers in the Firefox source).
Apparently this behavior may actually be something that defaults to whatever the PDF asks for (also, also). I run into this routinely because a lot of academic papers in PDF form trigger this Firefox behavior (for whatever reason), which is possibly some default inherited through LaTeX or some other common scientific PDF creator.
(PDF documents can apparently have some or all of outlines (which I would call tables of contents), attachments, and 'layers', whatever those are. Looking into how PDF works is always an adventure. I'm not sure if Firefox ever shows the sidebar by default if the PDF doesn't have any of them.)
Firefox's built in PDF viewer is called 'pdf.js' (also), and is nominally sort of a
stand alone project that Firefox incorporates (in this case, in
toolkit/components/pdfjs).
Currently the values for this can be found in the 'const SidebarView
'
declaration in eg viewer.js.
As of writing this entry, the values are:
UNKNOWN: -1, NONE: 0, THUMBS: 1, OUTLINE: 2, ATTACHMENTS: 3, LAYERS: 4
The default value of pdfjs.sidebarViewOnLoad is -1, which apparently
leaves it to whatever the PDF asked for (if the information above
is correct). I believe that this default (and the default for all
of the other pdfjs preferences) can be seen in
PdfJsDefaultPreferences.sys.mjs,
although maybe modules/libpref/init/all.js
and browser/app/profile/firefox.js
are also relevant. Don't ask me, I just run searches over the Firefox
source code tree. In any case, your 'about:config
' for 'pdfjs.'
entries is the authoritative source for your current values.
As far as I know, there's no Preferences UI for any pdf.js settings and pdf.js itself doesn't seem to have such a thing, although I believe that it may remember per-document settings until you restart your Firefox.
(A number of things in Firefox remember per-document or per-host settings in memory, so more or less until Firefox restarts. Other per-host settings, such as your zoom level, are stashed away somewhere that's not exposed in Preferences or about:config.)