Have Firefox prompt whether to open PDF in browser, or in external application, or for saving?











up vote
4
down vote

favorite
2












How can I get Firefox to give me a prompt, -- either natively, or through a plug-in, -- which will ask me:




  • if I want to preview the PDF in the browser using pdfjs, or

  • if I want to open the PDF in external application, or

  • if I want to save the PDF as file?


This is my current behavior, Firefox 36, Ubuntu 11.04, running in --safe-mode, and with the default profile; first I look up a PDF to open



/tmp/ff1.png



(Note: Google, when used with JavaScript, will rewrite each and every link upon mouse click, resulting with a stupid blank page when opening a PDF)



Upon click on a PDF link I get this prompt:



/tmp/ff2.png



Notably, I can either choose an external application (also via Other), or to save the file - but there is no option to preview in browser (implying use of pdfjs).



The Edit/Preferences/Applications looks like this:



/tmp/ff3.png



... and about:config settings related to pdf look like this (for some reason, taking a screenshot in Gnome 2 always seems to want to close the menubar, resulting with the crooked image below):



/tmp/ff4.png



What can I do to have all three options presented as choices when I click on a PDF link?










share|improve this question


















  • 1




    If you want to preview a PDF using Firefox built-in PDF viewer set PDF as the default application to handle PDF files. You can then still use Other to your typical PDF viewer.
    – Ramhound
    Mar 2 '15 at 14:42










  • Thanks @Ramhound - but if Firefox built-in PDF viewer is set as default application, then I get no prompt whatsoever; the PDF just opens directly in Firefox when I click on it, without asking me anything in a prompt first? And what I want is to be prompted about it...
    – sdaau
    Mar 2 '15 at 14:44








  • 1




    So pick Other and then select Firefox.
    – Ramhound
    Mar 2 '15 at 14:46












  • Thanks, @Ramhound - I'll give that a try; but wouldn't that open Firefox in a new instance? I'd like the PDF opened as preview in the same instance, when I choose to do so ... EDIT: just tried it, opens in new instance (even asks for a profile choice at start with --safe-mode) - this is bound to get recursive without ever opening the PDF.
    – sdaau
    Mar 2 '15 at 14:47








  • 1




    @clearkimura I tried that app and it doesn't work as expected for me as well.
    – phg
    Nov 29 at 12:20















up vote
4
down vote

favorite
2












How can I get Firefox to give me a prompt, -- either natively, or through a plug-in, -- which will ask me:




  • if I want to preview the PDF in the browser using pdfjs, or

  • if I want to open the PDF in external application, or

  • if I want to save the PDF as file?


This is my current behavior, Firefox 36, Ubuntu 11.04, running in --safe-mode, and with the default profile; first I look up a PDF to open



/tmp/ff1.png



(Note: Google, when used with JavaScript, will rewrite each and every link upon mouse click, resulting with a stupid blank page when opening a PDF)



Upon click on a PDF link I get this prompt:



/tmp/ff2.png



Notably, I can either choose an external application (also via Other), or to save the file - but there is no option to preview in browser (implying use of pdfjs).



The Edit/Preferences/Applications looks like this:



/tmp/ff3.png



... and about:config settings related to pdf look like this (for some reason, taking a screenshot in Gnome 2 always seems to want to close the menubar, resulting with the crooked image below):



/tmp/ff4.png



What can I do to have all three options presented as choices when I click on a PDF link?










share|improve this question


















  • 1




    If you want to preview a PDF using Firefox built-in PDF viewer set PDF as the default application to handle PDF files. You can then still use Other to your typical PDF viewer.
    – Ramhound
    Mar 2 '15 at 14:42










  • Thanks @Ramhound - but if Firefox built-in PDF viewer is set as default application, then I get no prompt whatsoever; the PDF just opens directly in Firefox when I click on it, without asking me anything in a prompt first? And what I want is to be prompted about it...
    – sdaau
    Mar 2 '15 at 14:44








  • 1




    So pick Other and then select Firefox.
    – Ramhound
    Mar 2 '15 at 14:46












  • Thanks, @Ramhound - I'll give that a try; but wouldn't that open Firefox in a new instance? I'd like the PDF opened as preview in the same instance, when I choose to do so ... EDIT: just tried it, opens in new instance (even asks for a profile choice at start with --safe-mode) - this is bound to get recursive without ever opening the PDF.
    – sdaau
    Mar 2 '15 at 14:47








  • 1




    @clearkimura I tried that app and it doesn't work as expected for me as well.
    – phg
    Nov 29 at 12:20













up vote
4
down vote

favorite
2









up vote
4
down vote

favorite
2






2





How can I get Firefox to give me a prompt, -- either natively, or through a plug-in, -- which will ask me:




  • if I want to preview the PDF in the browser using pdfjs, or

  • if I want to open the PDF in external application, or

  • if I want to save the PDF as file?


This is my current behavior, Firefox 36, Ubuntu 11.04, running in --safe-mode, and with the default profile; first I look up a PDF to open



/tmp/ff1.png



(Note: Google, when used with JavaScript, will rewrite each and every link upon mouse click, resulting with a stupid blank page when opening a PDF)



Upon click on a PDF link I get this prompt:



/tmp/ff2.png



Notably, I can either choose an external application (also via Other), or to save the file - but there is no option to preview in browser (implying use of pdfjs).



The Edit/Preferences/Applications looks like this:



/tmp/ff3.png



... and about:config settings related to pdf look like this (for some reason, taking a screenshot in Gnome 2 always seems to want to close the menubar, resulting with the crooked image below):



/tmp/ff4.png



What can I do to have all three options presented as choices when I click on a PDF link?










share|improve this question













How can I get Firefox to give me a prompt, -- either natively, or through a plug-in, -- which will ask me:




  • if I want to preview the PDF in the browser using pdfjs, or

  • if I want to open the PDF in external application, or

  • if I want to save the PDF as file?


This is my current behavior, Firefox 36, Ubuntu 11.04, running in --safe-mode, and with the default profile; first I look up a PDF to open



/tmp/ff1.png



(Note: Google, when used with JavaScript, will rewrite each and every link upon mouse click, resulting with a stupid blank page when opening a PDF)



Upon click on a PDF link I get this prompt:



/tmp/ff2.png



Notably, I can either choose an external application (also via Other), or to save the file - but there is no option to preview in browser (implying use of pdfjs).



The Edit/Preferences/Applications looks like this:



/tmp/ff3.png



... and about:config settings related to pdf look like this (for some reason, taking a screenshot in Gnome 2 always seems to want to close the menubar, resulting with the crooked image below):



/tmp/ff4.png



What can I do to have all three options presented as choices when I click on a PDF link?







firefox pdf firefox-extensions






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 2 '15 at 14:39









sdaau

2,39543657




2,39543657








  • 1




    If you want to preview a PDF using Firefox built-in PDF viewer set PDF as the default application to handle PDF files. You can then still use Other to your typical PDF viewer.
    – Ramhound
    Mar 2 '15 at 14:42










  • Thanks @Ramhound - but if Firefox built-in PDF viewer is set as default application, then I get no prompt whatsoever; the PDF just opens directly in Firefox when I click on it, without asking me anything in a prompt first? And what I want is to be prompted about it...
    – sdaau
    Mar 2 '15 at 14:44








  • 1




    So pick Other and then select Firefox.
    – Ramhound
    Mar 2 '15 at 14:46












  • Thanks, @Ramhound - I'll give that a try; but wouldn't that open Firefox in a new instance? I'd like the PDF opened as preview in the same instance, when I choose to do so ... EDIT: just tried it, opens in new instance (even asks for a profile choice at start with --safe-mode) - this is bound to get recursive without ever opening the PDF.
    – sdaau
    Mar 2 '15 at 14:47








  • 1




    @clearkimura I tried that app and it doesn't work as expected for me as well.
    – phg
    Nov 29 at 12:20














  • 1




    If you want to preview a PDF using Firefox built-in PDF viewer set PDF as the default application to handle PDF files. You can then still use Other to your typical PDF viewer.
    – Ramhound
    Mar 2 '15 at 14:42










  • Thanks @Ramhound - but if Firefox built-in PDF viewer is set as default application, then I get no prompt whatsoever; the PDF just opens directly in Firefox when I click on it, without asking me anything in a prompt first? And what I want is to be prompted about it...
    – sdaau
    Mar 2 '15 at 14:44








  • 1




    So pick Other and then select Firefox.
    – Ramhound
    Mar 2 '15 at 14:46












  • Thanks, @Ramhound - I'll give that a try; but wouldn't that open Firefox in a new instance? I'd like the PDF opened as preview in the same instance, when I choose to do so ... EDIT: just tried it, opens in new instance (even asks for a profile choice at start with --safe-mode) - this is bound to get recursive without ever opening the PDF.
    – sdaau
    Mar 2 '15 at 14:47








  • 1




    @clearkimura I tried that app and it doesn't work as expected for me as well.
    – phg
    Nov 29 at 12:20








1




1




If you want to preview a PDF using Firefox built-in PDF viewer set PDF as the default application to handle PDF files. You can then still use Other to your typical PDF viewer.
– Ramhound
Mar 2 '15 at 14:42




If you want to preview a PDF using Firefox built-in PDF viewer set PDF as the default application to handle PDF files. You can then still use Other to your typical PDF viewer.
– Ramhound
Mar 2 '15 at 14:42












Thanks @Ramhound - but if Firefox built-in PDF viewer is set as default application, then I get no prompt whatsoever; the PDF just opens directly in Firefox when I click on it, without asking me anything in a prompt first? And what I want is to be prompted about it...
– sdaau
Mar 2 '15 at 14:44






Thanks @Ramhound - but if Firefox built-in PDF viewer is set as default application, then I get no prompt whatsoever; the PDF just opens directly in Firefox when I click on it, without asking me anything in a prompt first? And what I want is to be prompted about it...
– sdaau
Mar 2 '15 at 14:44






1




1




So pick Other and then select Firefox.
– Ramhound
Mar 2 '15 at 14:46






So pick Other and then select Firefox.
– Ramhound
Mar 2 '15 at 14:46














Thanks, @Ramhound - I'll give that a try; but wouldn't that open Firefox in a new instance? I'd like the PDF opened as preview in the same instance, when I choose to do so ... EDIT: just tried it, opens in new instance (even asks for a profile choice at start with --safe-mode) - this is bound to get recursive without ever opening the PDF.
– sdaau
Mar 2 '15 at 14:47






Thanks, @Ramhound - I'll give that a try; but wouldn't that open Firefox in a new instance? I'd like the PDF opened as preview in the same instance, when I choose to do so ... EDIT: just tried it, opens in new instance (even asks for a profile choice at start with --safe-mode) - this is bound to get recursive without ever opening the PDF.
– sdaau
Mar 2 '15 at 14:47






1




1




@clearkimura I tried that app and it doesn't work as expected for me as well.
– phg
Nov 29 at 12:20




@clearkimura I tried that app and it doesn't work as expected for me as well.
– phg
Nov 29 at 12:20










1 Answer
1






active

oldest

votes

















up vote
1
down vote



+50










This can be either a workaround or an answer, based on the original post asked by @sdaau and the attention brought by @phg. This is a practical solution anyway.



Direct answers




What can I do to have all three options presented as choices when I click on a PDF link? - sdaau asked Mar 2 '15 at 14:39




No, that is not possible. Firefox Addon may provide such interface but with newer addons using WebExtensions API, any direct modification to Firefox is not possible. Therefore the solution I have written here, with respect to OP, is a workaround.




I really want this, too. It's now three years and 30 versions later, has nobody come up with a solution yet? – phg Nov 28 at 10:27




Yes, that actually exist from before. Except nobody really wrote the solution until now; neither the help article for Firefox nor related SE sites had any-relevant-post with the solution yet.



Firefox limitation 1: The built-in viewer PDF.js is not an application by itself, and that makes impossible to set that as helper application within Firefox. Therefore "Preview in Firefox" can not be selected from "Open with" in the save dialog.



Hence the practical solution is to make the current profile of Firefox call another instance of Firefox that uses a separate profile that has been set to "Preview in Firefox" by default.



How it works



To understand the solution, user ought to know that:




  • User can change what Firefox does when you click on or download a file, as noted by this help article on Firefox Help

  • Firefox can run multiple instances by creating separate user profiles, as noted by this article on MozillaZine Knowledge Base

  • Script can be used to run an application, often with command line arguments, on Windows, macOS, and Linux, as noted by respective posts on SU

  • Any program, including Firefox, will most likely provide the full path to open the content, which must be parsed via command line argument (invisible to users, apparent to programmers)


Whenever the user open a link that has the content type, such as PDF, user will see the save dialog, then select other application from "Open with" and that is all.



In practice however, user may fail to choose from "Open with" because the application of choice is not listed there. Some setup is actually required, hence the missing step.



Missing step: User will have to add the application of choice. Typical help articles might not help, especially if the application of choice is a custom application or something built-in within an application like the built-in viewer of Firefox.



How to setup



To actually add the application of choice, in this case the built-in viewer of Firefox, user must do all the following beforehand:




  • Create a new user profile in Firefox, and

  • Create a script to run Firefox using the new user profile, and

  • Add the script to the settings under Applications in Firefox.


First, create a new user profile named pdfjs (any name of choice). Then create a Bash script (Linux) with only two lines as follows.



#!/bin/bash
firefox -P "pdfjs" --no-remote $1


Where by:





  • -P "pdfjs" is to specify the separate user profile


  • --no-remote option to allow multiple instances of Firefox with different profiles


  • $1 is the first argument in Bash, which likely has the full path to open the content


Firefox limitation 2: Firefox can not run multiple instances of same profile. User can open new tab or window from Firefox itself, but can not do the same via command line. This limitation does not apply to the default profile that run Firefox command without any option.



The script is saved at /usr/local/bin/pdfjs (similar name with user profile, my naming choice) and the script must be marked as executable.




  • If not marked as executable, Firefox will not recognize the script as a helper application.

  • Firefox will recognize Linux shortcut '.desktop' that is made executable, but does not work.

  • Instead of a shortcut, use a script.


The following screenshot combo shows to select "Use other..." (top left) and locate the script in settings of Firefox and then change the action.



Firefox - Select helper application



If the script was successfully added, user can see the script name being listed in the "Action" column and also "Application details" (right). Finally, change the action again to "Always ask" (bottom left).



Setup summary



To add the built-in viewer as the application of choice in Firefox:




  1. Run Firefox profile chooser and create new profile

  2. Run a text editor and create a script to run Firefox using the new profile with option and command line argument (file content as above), then mark as executable

  3. Firefox - Settings/Preferences


  4. General > Applications > Portable Document Format (PDF) - Use other... - Select Helper Application (locate where the script was saved)

  5. General > Applications > Portable Document Format (PDF) - Always ask


  6. Close to finish


All relevant steps 3 until 6 are done in Firefox with default profile.



The steps 4 and 5 are done in succession to simplify the setup. These steps seem contradictory, but both indeed have own purpose each.




  • Step 4 is to add the application of choice and make available in "Open with".

  • Step 5 is to show the save dialog, so that user can select "Open with" and see the application of choice that was made available. This does not remove the added choice in step 4.

  • What seem contradictory here is related to Firefox limitation 1 explained earlier.


Other details have been explained under "How to setup".



How to use



Same as usual: Run Firefox and open a link with the content type. The save dialog will appear, then select "Open with" and select the application of choice. Click OK to run the choice.



The following screenshot combo shows Firefox with separate profile uses Dark theme (bottom) to distinguish from Firefox with default profile (top).



Firefox - Open with helper application



Limitation review: This solution allows to open PDF in Firefox with separate profile only one at a time. If the user want to open more than one, just drag and drop the link to PDF from Firefox (default profile) to the tab bar of another Firefox (separate profile) to open another PDF in a new tab.



Tested working with Firefox 63.0 and Bash script on Linux. Any release since Firefox 3.0 (three-point-zero) will do, except not tested with other scripts on Windows and macOS.



TL;DR The solution exists from before, but nobody wrote about that. Just add the application of choice. Tedious setup due to Firefox limitation. Native way is more practical than using addons.






share|improve this answer





















  • This is an excellent diagnose of what's happening, and your solution is probably as good as it gets. While I won' use it, since it kind of defeats the purpuse of having a PDF open in the same tab, it answers the question.
    – phg
    Dec 5 at 9:52











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f884533%2fhave-firefox-prompt-whether-to-open-pdf-in-browser-or-in-external-application%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



+50










This can be either a workaround or an answer, based on the original post asked by @sdaau and the attention brought by @phg. This is a practical solution anyway.



Direct answers




What can I do to have all three options presented as choices when I click on a PDF link? - sdaau asked Mar 2 '15 at 14:39




No, that is not possible. Firefox Addon may provide such interface but with newer addons using WebExtensions API, any direct modification to Firefox is not possible. Therefore the solution I have written here, with respect to OP, is a workaround.




I really want this, too. It's now three years and 30 versions later, has nobody come up with a solution yet? – phg Nov 28 at 10:27




Yes, that actually exist from before. Except nobody really wrote the solution until now; neither the help article for Firefox nor related SE sites had any-relevant-post with the solution yet.



Firefox limitation 1: The built-in viewer PDF.js is not an application by itself, and that makes impossible to set that as helper application within Firefox. Therefore "Preview in Firefox" can not be selected from "Open with" in the save dialog.



Hence the practical solution is to make the current profile of Firefox call another instance of Firefox that uses a separate profile that has been set to "Preview in Firefox" by default.



How it works



To understand the solution, user ought to know that:




  • User can change what Firefox does when you click on or download a file, as noted by this help article on Firefox Help

  • Firefox can run multiple instances by creating separate user profiles, as noted by this article on MozillaZine Knowledge Base

  • Script can be used to run an application, often with command line arguments, on Windows, macOS, and Linux, as noted by respective posts on SU

  • Any program, including Firefox, will most likely provide the full path to open the content, which must be parsed via command line argument (invisible to users, apparent to programmers)


Whenever the user open a link that has the content type, such as PDF, user will see the save dialog, then select other application from "Open with" and that is all.



In practice however, user may fail to choose from "Open with" because the application of choice is not listed there. Some setup is actually required, hence the missing step.



Missing step: User will have to add the application of choice. Typical help articles might not help, especially if the application of choice is a custom application or something built-in within an application like the built-in viewer of Firefox.



How to setup



To actually add the application of choice, in this case the built-in viewer of Firefox, user must do all the following beforehand:




  • Create a new user profile in Firefox, and

  • Create a script to run Firefox using the new user profile, and

  • Add the script to the settings under Applications in Firefox.


First, create a new user profile named pdfjs (any name of choice). Then create a Bash script (Linux) with only two lines as follows.



#!/bin/bash
firefox -P "pdfjs" --no-remote $1


Where by:





  • -P "pdfjs" is to specify the separate user profile


  • --no-remote option to allow multiple instances of Firefox with different profiles


  • $1 is the first argument in Bash, which likely has the full path to open the content


Firefox limitation 2: Firefox can not run multiple instances of same profile. User can open new tab or window from Firefox itself, but can not do the same via command line. This limitation does not apply to the default profile that run Firefox command without any option.



The script is saved at /usr/local/bin/pdfjs (similar name with user profile, my naming choice) and the script must be marked as executable.




  • If not marked as executable, Firefox will not recognize the script as a helper application.

  • Firefox will recognize Linux shortcut '.desktop' that is made executable, but does not work.

  • Instead of a shortcut, use a script.


The following screenshot combo shows to select "Use other..." (top left) and locate the script in settings of Firefox and then change the action.



Firefox - Select helper application



If the script was successfully added, user can see the script name being listed in the "Action" column and also "Application details" (right). Finally, change the action again to "Always ask" (bottom left).



Setup summary



To add the built-in viewer as the application of choice in Firefox:




  1. Run Firefox profile chooser and create new profile

  2. Run a text editor and create a script to run Firefox using the new profile with option and command line argument (file content as above), then mark as executable

  3. Firefox - Settings/Preferences


  4. General > Applications > Portable Document Format (PDF) - Use other... - Select Helper Application (locate where the script was saved)

  5. General > Applications > Portable Document Format (PDF) - Always ask


  6. Close to finish


All relevant steps 3 until 6 are done in Firefox with default profile.



The steps 4 and 5 are done in succession to simplify the setup. These steps seem contradictory, but both indeed have own purpose each.




  • Step 4 is to add the application of choice and make available in "Open with".

  • Step 5 is to show the save dialog, so that user can select "Open with" and see the application of choice that was made available. This does not remove the added choice in step 4.

  • What seem contradictory here is related to Firefox limitation 1 explained earlier.


Other details have been explained under "How to setup".



How to use



Same as usual: Run Firefox and open a link with the content type. The save dialog will appear, then select "Open with" and select the application of choice. Click OK to run the choice.



The following screenshot combo shows Firefox with separate profile uses Dark theme (bottom) to distinguish from Firefox with default profile (top).



Firefox - Open with helper application



Limitation review: This solution allows to open PDF in Firefox with separate profile only one at a time. If the user want to open more than one, just drag and drop the link to PDF from Firefox (default profile) to the tab bar of another Firefox (separate profile) to open another PDF in a new tab.



Tested working with Firefox 63.0 and Bash script on Linux. Any release since Firefox 3.0 (three-point-zero) will do, except not tested with other scripts on Windows and macOS.



TL;DR The solution exists from before, but nobody wrote about that. Just add the application of choice. Tedious setup due to Firefox limitation. Native way is more practical than using addons.






share|improve this answer





















  • This is an excellent diagnose of what's happening, and your solution is probably as good as it gets. While I won' use it, since it kind of defeats the purpuse of having a PDF open in the same tab, it answers the question.
    – phg
    Dec 5 at 9:52















up vote
1
down vote



+50










This can be either a workaround or an answer, based on the original post asked by @sdaau and the attention brought by @phg. This is a practical solution anyway.



Direct answers




What can I do to have all three options presented as choices when I click on a PDF link? - sdaau asked Mar 2 '15 at 14:39




No, that is not possible. Firefox Addon may provide such interface but with newer addons using WebExtensions API, any direct modification to Firefox is not possible. Therefore the solution I have written here, with respect to OP, is a workaround.




I really want this, too. It's now three years and 30 versions later, has nobody come up with a solution yet? – phg Nov 28 at 10:27




Yes, that actually exist from before. Except nobody really wrote the solution until now; neither the help article for Firefox nor related SE sites had any-relevant-post with the solution yet.



Firefox limitation 1: The built-in viewer PDF.js is not an application by itself, and that makes impossible to set that as helper application within Firefox. Therefore "Preview in Firefox" can not be selected from "Open with" in the save dialog.



Hence the practical solution is to make the current profile of Firefox call another instance of Firefox that uses a separate profile that has been set to "Preview in Firefox" by default.



How it works



To understand the solution, user ought to know that:




  • User can change what Firefox does when you click on or download a file, as noted by this help article on Firefox Help

  • Firefox can run multiple instances by creating separate user profiles, as noted by this article on MozillaZine Knowledge Base

  • Script can be used to run an application, often with command line arguments, on Windows, macOS, and Linux, as noted by respective posts on SU

  • Any program, including Firefox, will most likely provide the full path to open the content, which must be parsed via command line argument (invisible to users, apparent to programmers)


Whenever the user open a link that has the content type, such as PDF, user will see the save dialog, then select other application from "Open with" and that is all.



In practice however, user may fail to choose from "Open with" because the application of choice is not listed there. Some setup is actually required, hence the missing step.



Missing step: User will have to add the application of choice. Typical help articles might not help, especially if the application of choice is a custom application or something built-in within an application like the built-in viewer of Firefox.



How to setup



To actually add the application of choice, in this case the built-in viewer of Firefox, user must do all the following beforehand:




  • Create a new user profile in Firefox, and

  • Create a script to run Firefox using the new user profile, and

  • Add the script to the settings under Applications in Firefox.


First, create a new user profile named pdfjs (any name of choice). Then create a Bash script (Linux) with only two lines as follows.



#!/bin/bash
firefox -P "pdfjs" --no-remote $1


Where by:





  • -P "pdfjs" is to specify the separate user profile


  • --no-remote option to allow multiple instances of Firefox with different profiles


  • $1 is the first argument in Bash, which likely has the full path to open the content


Firefox limitation 2: Firefox can not run multiple instances of same profile. User can open new tab or window from Firefox itself, but can not do the same via command line. This limitation does not apply to the default profile that run Firefox command without any option.



The script is saved at /usr/local/bin/pdfjs (similar name with user profile, my naming choice) and the script must be marked as executable.




  • If not marked as executable, Firefox will not recognize the script as a helper application.

  • Firefox will recognize Linux shortcut '.desktop' that is made executable, but does not work.

  • Instead of a shortcut, use a script.


The following screenshot combo shows to select "Use other..." (top left) and locate the script in settings of Firefox and then change the action.



Firefox - Select helper application



If the script was successfully added, user can see the script name being listed in the "Action" column and also "Application details" (right). Finally, change the action again to "Always ask" (bottom left).



Setup summary



To add the built-in viewer as the application of choice in Firefox:




  1. Run Firefox profile chooser and create new profile

  2. Run a text editor and create a script to run Firefox using the new profile with option and command line argument (file content as above), then mark as executable

  3. Firefox - Settings/Preferences


  4. General > Applications > Portable Document Format (PDF) - Use other... - Select Helper Application (locate where the script was saved)

  5. General > Applications > Portable Document Format (PDF) - Always ask


  6. Close to finish


All relevant steps 3 until 6 are done in Firefox with default profile.



The steps 4 and 5 are done in succession to simplify the setup. These steps seem contradictory, but both indeed have own purpose each.




  • Step 4 is to add the application of choice and make available in "Open with".

  • Step 5 is to show the save dialog, so that user can select "Open with" and see the application of choice that was made available. This does not remove the added choice in step 4.

  • What seem contradictory here is related to Firefox limitation 1 explained earlier.


Other details have been explained under "How to setup".



How to use



Same as usual: Run Firefox and open a link with the content type. The save dialog will appear, then select "Open with" and select the application of choice. Click OK to run the choice.



The following screenshot combo shows Firefox with separate profile uses Dark theme (bottom) to distinguish from Firefox with default profile (top).



Firefox - Open with helper application



Limitation review: This solution allows to open PDF in Firefox with separate profile only one at a time. If the user want to open more than one, just drag and drop the link to PDF from Firefox (default profile) to the tab bar of another Firefox (separate profile) to open another PDF in a new tab.



Tested working with Firefox 63.0 and Bash script on Linux. Any release since Firefox 3.0 (three-point-zero) will do, except not tested with other scripts on Windows and macOS.



TL;DR The solution exists from before, but nobody wrote about that. Just add the application of choice. Tedious setup due to Firefox limitation. Native way is more practical than using addons.






share|improve this answer





















  • This is an excellent diagnose of what's happening, and your solution is probably as good as it gets. While I won' use it, since it kind of defeats the purpuse of having a PDF open in the same tab, it answers the question.
    – phg
    Dec 5 at 9:52













up vote
1
down vote



+50







up vote
1
down vote



+50




+50




This can be either a workaround or an answer, based on the original post asked by @sdaau and the attention brought by @phg. This is a practical solution anyway.



Direct answers




What can I do to have all three options presented as choices when I click on a PDF link? - sdaau asked Mar 2 '15 at 14:39




No, that is not possible. Firefox Addon may provide such interface but with newer addons using WebExtensions API, any direct modification to Firefox is not possible. Therefore the solution I have written here, with respect to OP, is a workaround.




I really want this, too. It's now three years and 30 versions later, has nobody come up with a solution yet? – phg Nov 28 at 10:27




Yes, that actually exist from before. Except nobody really wrote the solution until now; neither the help article for Firefox nor related SE sites had any-relevant-post with the solution yet.



Firefox limitation 1: The built-in viewer PDF.js is not an application by itself, and that makes impossible to set that as helper application within Firefox. Therefore "Preview in Firefox" can not be selected from "Open with" in the save dialog.



Hence the practical solution is to make the current profile of Firefox call another instance of Firefox that uses a separate profile that has been set to "Preview in Firefox" by default.



How it works



To understand the solution, user ought to know that:




  • User can change what Firefox does when you click on or download a file, as noted by this help article on Firefox Help

  • Firefox can run multiple instances by creating separate user profiles, as noted by this article on MozillaZine Knowledge Base

  • Script can be used to run an application, often with command line arguments, on Windows, macOS, and Linux, as noted by respective posts on SU

  • Any program, including Firefox, will most likely provide the full path to open the content, which must be parsed via command line argument (invisible to users, apparent to programmers)


Whenever the user open a link that has the content type, such as PDF, user will see the save dialog, then select other application from "Open with" and that is all.



In practice however, user may fail to choose from "Open with" because the application of choice is not listed there. Some setup is actually required, hence the missing step.



Missing step: User will have to add the application of choice. Typical help articles might not help, especially if the application of choice is a custom application or something built-in within an application like the built-in viewer of Firefox.



How to setup



To actually add the application of choice, in this case the built-in viewer of Firefox, user must do all the following beforehand:




  • Create a new user profile in Firefox, and

  • Create a script to run Firefox using the new user profile, and

  • Add the script to the settings under Applications in Firefox.


First, create a new user profile named pdfjs (any name of choice). Then create a Bash script (Linux) with only two lines as follows.



#!/bin/bash
firefox -P "pdfjs" --no-remote $1


Where by:





  • -P "pdfjs" is to specify the separate user profile


  • --no-remote option to allow multiple instances of Firefox with different profiles


  • $1 is the first argument in Bash, which likely has the full path to open the content


Firefox limitation 2: Firefox can not run multiple instances of same profile. User can open new tab or window from Firefox itself, but can not do the same via command line. This limitation does not apply to the default profile that run Firefox command without any option.



The script is saved at /usr/local/bin/pdfjs (similar name with user profile, my naming choice) and the script must be marked as executable.




  • If not marked as executable, Firefox will not recognize the script as a helper application.

  • Firefox will recognize Linux shortcut '.desktop' that is made executable, but does not work.

  • Instead of a shortcut, use a script.


The following screenshot combo shows to select "Use other..." (top left) and locate the script in settings of Firefox and then change the action.



Firefox - Select helper application



If the script was successfully added, user can see the script name being listed in the "Action" column and also "Application details" (right). Finally, change the action again to "Always ask" (bottom left).



Setup summary



To add the built-in viewer as the application of choice in Firefox:




  1. Run Firefox profile chooser and create new profile

  2. Run a text editor and create a script to run Firefox using the new profile with option and command line argument (file content as above), then mark as executable

  3. Firefox - Settings/Preferences


  4. General > Applications > Portable Document Format (PDF) - Use other... - Select Helper Application (locate where the script was saved)

  5. General > Applications > Portable Document Format (PDF) - Always ask


  6. Close to finish


All relevant steps 3 until 6 are done in Firefox with default profile.



The steps 4 and 5 are done in succession to simplify the setup. These steps seem contradictory, but both indeed have own purpose each.




  • Step 4 is to add the application of choice and make available in "Open with".

  • Step 5 is to show the save dialog, so that user can select "Open with" and see the application of choice that was made available. This does not remove the added choice in step 4.

  • What seem contradictory here is related to Firefox limitation 1 explained earlier.


Other details have been explained under "How to setup".



How to use



Same as usual: Run Firefox and open a link with the content type. The save dialog will appear, then select "Open with" and select the application of choice. Click OK to run the choice.



The following screenshot combo shows Firefox with separate profile uses Dark theme (bottom) to distinguish from Firefox with default profile (top).



Firefox - Open with helper application



Limitation review: This solution allows to open PDF in Firefox with separate profile only one at a time. If the user want to open more than one, just drag and drop the link to PDF from Firefox (default profile) to the tab bar of another Firefox (separate profile) to open another PDF in a new tab.



Tested working with Firefox 63.0 and Bash script on Linux. Any release since Firefox 3.0 (three-point-zero) will do, except not tested with other scripts on Windows and macOS.



TL;DR The solution exists from before, but nobody wrote about that. Just add the application of choice. Tedious setup due to Firefox limitation. Native way is more practical than using addons.






share|improve this answer












This can be either a workaround or an answer, based on the original post asked by @sdaau and the attention brought by @phg. This is a practical solution anyway.



Direct answers




What can I do to have all three options presented as choices when I click on a PDF link? - sdaau asked Mar 2 '15 at 14:39




No, that is not possible. Firefox Addon may provide such interface but with newer addons using WebExtensions API, any direct modification to Firefox is not possible. Therefore the solution I have written here, with respect to OP, is a workaround.




I really want this, too. It's now three years and 30 versions later, has nobody come up with a solution yet? – phg Nov 28 at 10:27




Yes, that actually exist from before. Except nobody really wrote the solution until now; neither the help article for Firefox nor related SE sites had any-relevant-post with the solution yet.



Firefox limitation 1: The built-in viewer PDF.js is not an application by itself, and that makes impossible to set that as helper application within Firefox. Therefore "Preview in Firefox" can not be selected from "Open with" in the save dialog.



Hence the practical solution is to make the current profile of Firefox call another instance of Firefox that uses a separate profile that has been set to "Preview in Firefox" by default.



How it works



To understand the solution, user ought to know that:




  • User can change what Firefox does when you click on or download a file, as noted by this help article on Firefox Help

  • Firefox can run multiple instances by creating separate user profiles, as noted by this article on MozillaZine Knowledge Base

  • Script can be used to run an application, often with command line arguments, on Windows, macOS, and Linux, as noted by respective posts on SU

  • Any program, including Firefox, will most likely provide the full path to open the content, which must be parsed via command line argument (invisible to users, apparent to programmers)


Whenever the user open a link that has the content type, such as PDF, user will see the save dialog, then select other application from "Open with" and that is all.



In practice however, user may fail to choose from "Open with" because the application of choice is not listed there. Some setup is actually required, hence the missing step.



Missing step: User will have to add the application of choice. Typical help articles might not help, especially if the application of choice is a custom application or something built-in within an application like the built-in viewer of Firefox.



How to setup



To actually add the application of choice, in this case the built-in viewer of Firefox, user must do all the following beforehand:




  • Create a new user profile in Firefox, and

  • Create a script to run Firefox using the new user profile, and

  • Add the script to the settings under Applications in Firefox.


First, create a new user profile named pdfjs (any name of choice). Then create a Bash script (Linux) with only two lines as follows.



#!/bin/bash
firefox -P "pdfjs" --no-remote $1


Where by:





  • -P "pdfjs" is to specify the separate user profile


  • --no-remote option to allow multiple instances of Firefox with different profiles


  • $1 is the first argument in Bash, which likely has the full path to open the content


Firefox limitation 2: Firefox can not run multiple instances of same profile. User can open new tab or window from Firefox itself, but can not do the same via command line. This limitation does not apply to the default profile that run Firefox command without any option.



The script is saved at /usr/local/bin/pdfjs (similar name with user profile, my naming choice) and the script must be marked as executable.




  • If not marked as executable, Firefox will not recognize the script as a helper application.

  • Firefox will recognize Linux shortcut '.desktop' that is made executable, but does not work.

  • Instead of a shortcut, use a script.


The following screenshot combo shows to select "Use other..." (top left) and locate the script in settings of Firefox and then change the action.



Firefox - Select helper application



If the script was successfully added, user can see the script name being listed in the "Action" column and also "Application details" (right). Finally, change the action again to "Always ask" (bottom left).



Setup summary



To add the built-in viewer as the application of choice in Firefox:




  1. Run Firefox profile chooser and create new profile

  2. Run a text editor and create a script to run Firefox using the new profile with option and command line argument (file content as above), then mark as executable

  3. Firefox - Settings/Preferences


  4. General > Applications > Portable Document Format (PDF) - Use other... - Select Helper Application (locate where the script was saved)

  5. General > Applications > Portable Document Format (PDF) - Always ask


  6. Close to finish


All relevant steps 3 until 6 are done in Firefox with default profile.



The steps 4 and 5 are done in succession to simplify the setup. These steps seem contradictory, but both indeed have own purpose each.




  • Step 4 is to add the application of choice and make available in "Open with".

  • Step 5 is to show the save dialog, so that user can select "Open with" and see the application of choice that was made available. This does not remove the added choice in step 4.

  • What seem contradictory here is related to Firefox limitation 1 explained earlier.


Other details have been explained under "How to setup".



How to use



Same as usual: Run Firefox and open a link with the content type. The save dialog will appear, then select "Open with" and select the application of choice. Click OK to run the choice.



The following screenshot combo shows Firefox with separate profile uses Dark theme (bottom) to distinguish from Firefox with default profile (top).



Firefox - Open with helper application



Limitation review: This solution allows to open PDF in Firefox with separate profile only one at a time. If the user want to open more than one, just drag and drop the link to PDF from Firefox (default profile) to the tab bar of another Firefox (separate profile) to open another PDF in a new tab.



Tested working with Firefox 63.0 and Bash script on Linux. Any release since Firefox 3.0 (three-point-zero) will do, except not tested with other scripts on Windows and macOS.



TL;DR The solution exists from before, but nobody wrote about that. Just add the application of choice. Tedious setup due to Firefox limitation. Native way is more practical than using addons.







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 5 at 7:48









clearkimura

2,2361529




2,2361529












  • This is an excellent diagnose of what's happening, and your solution is probably as good as it gets. While I won' use it, since it kind of defeats the purpuse of having a PDF open in the same tab, it answers the question.
    – phg
    Dec 5 at 9:52


















  • This is an excellent diagnose of what's happening, and your solution is probably as good as it gets. While I won' use it, since it kind of defeats the purpuse of having a PDF open in the same tab, it answers the question.
    – phg
    Dec 5 at 9:52
















This is an excellent diagnose of what's happening, and your solution is probably as good as it gets. While I won' use it, since it kind of defeats the purpuse of having a PDF open in the same tab, it answers the question.
– phg
Dec 5 at 9:52




This is an excellent diagnose of what's happening, and your solution is probably as good as it gets. While I won' use it, since it kind of defeats the purpuse of having a PDF open in the same tab, it answers the question.
– phg
Dec 5 at 9:52


















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f884533%2fhave-firefox-prompt-whether-to-open-pdf-in-browser-or-in-external-application%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Plaza Victoria

In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...