6

Firefox can open pdfs, and for some purposes, it's pdf viewer is advantageous. In particular, the print menu has some options not available elsewhere.

Unfortunately, it's not registered as a program that reads pdfs. I don't want it as the default pdf viewer, but I do want it on the list of programs that appear when I select "open-with".

How can I arrange that?

1
  • I’ll answer how things work and hope someone is more clever and knows how to invoke the PDF handler and teach us all a new trick. This might be easy without needing to modify the app for someone that knows the insides of how this specific helper works
    – bmike
    Jul 6 at 13:54

3 Answers 3

9

You could edit Firefox's Firefox.app/Contents/Info.plist and add <string>pdf</string> e.g in the first CFBundleTypeExtensions array, but that would get ripped-off at the next Firefox update.

So instead you may prefer to build a new Automator Application that will open these files in Firefox.

So head to Automator, (Applications/Automator), "New" -> "Application".

On the left panel, search for "Open Finder Items", double click or drag&drop on the right panel. In the "Open with" option, select Firefox.app.

Screenshot of Automator setup as described

Now is alredy time to export our App ("File" > "Export").

Then we go with the Finder to the location where we just exported the App, right-click, "Show Package Content" > "Contents" and we open Info.plist with our favorite editor (TextEdit should be fine).

Search for the string <string>*</string> below CFBundleTypeExtensions and replace it with <string>pdf</string>.
Save the document and go back to the Finder looking for a pdf file. Right-click, "Open with" > "Other..." and there select our App.
Firefox should open said pdf file and our App should appear in the menu:

Screenshot of the Finder's context menu showing a new FirefoxPDF.app option

2
  • Exceptional clever and skilled solution. Well done!
    – bmike
    Jul 7 at 13:55
  • Thanks, at first I thought this didn't work, but actually I just needed to restart and check again.
    – Clumsy cat
    Jul 20 at 13:24
5

This doesn't actually answer the question, as it doesn't add it to the Open With list unfortunately. It only stays in the list if it's set as Default.
Frankly it's just quicker for a one-off to drop it straight on the Dock icon or right onto any open Firefox page.


You can do this from Get Info… in the same way as selecting any already-registered app, except you select 'Other…', right at the bottom of the 'Open With:' list.
Once the file-picker dialog opens set 'Enable' at the bottom to 'All Apps' & choose Firefox.

You can then set 'Change All…' back in the Get Info pane.

enter image description here

Alternatively, for anyone on an OS old enough to still be able to run RCDefaultApp [Mojave or earlier] you can do it in there. SwiftDefaultApps doesn't seem to be able to do it.

0
2

The short answer is you don’t. The developer of the application registers it (via code) to open file types using Apple SDK and API calls. Then macOS let’s you choose a preferred app from all that support the types of a file.

Also, it’s slightly more complicated than just PDF or pdf extension since each file has many types that are mapped in code so the more specific type gets precedence in choosing an app over the more general types that will get consulted if the first choice doesn’t match.

Firefox is happy to pass PDF to other apps, but I’m not clever enough to find the embedded viewer and see if it can trick it to tell macOS it can open PDF outside the Firefox main app.

In the mean time, what happens if you drag that PDF into Firefox windows or the icon?

2
  • Is the bit that tells macos what file types it can open a function of the compiled program itself, or its registration somewhere? If I wrote my own app, and wanted it to open an extension, how would I indicate that?
    – Clumsy cat
    Jul 6 at 23:22
  • Good question @Clumsycat the technical term for a file type (which isn’t just a preferred extension, it’s more nuanced) is Uniform Type identifiers and here is how an app extends and declares its intents - developer.apple.com/documentation/uniformtypeidentifiers/…
    – bmike
    Jul 7 at 13:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .