Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using Firefox 23.0.1. I want to totally disable printing from Firefox, is this possible?

I used about:config to set the following properties:

  • print.always_print_silent = true
  • print.show_print_progress = false

It gets me half the way there, Firefox prints silently and does not show any indications of printing. However the job is still sent to the default printer.

I then tried to set print_printer to an empty string since this seems to be the default printer, but it sill sends the job to that printer.

Is there any way to completely disable printing for Firefox, preferably through the settings in about:config?

I want to do this since I have automatic semi-load tests (using Selenium together with JMeter). In the application that is tested, a pdf is embedded which has a javascript sending the pdf to the default printer. If printing cannot be disabled, a lot of garbage jobs would be sent to the printer.

share|improve this question
1  
Well, can't you just not print? Or change the default printer? I think it may be useful if we know why you want this behaviour? –  Dave Sep 11 '13 at 10:04
1  
Please always include your OS. Solutions very often are dependent on the Operating System being used. Are you using Windows, Linux, Unix, OSX, BSD? Which version? –  terdon Sep 11 '13 at 10:09
    
@terdon Sorry about that. First post at SU. –  Magnilex Sep 11 '13 at 10:20
    
@DaveRook I will update my question with why I want this behaviour. –  Magnilex Sep 11 '13 at 10:20
    
@DaveRook Changing the default printer would work, but to what? I don't really want to clutter the file system either. –  Magnilex Sep 11 '13 at 10:25

2 Answers 2

up vote 4 down vote accepted

You can disable the JavaScript print function to prevent JS-initiated print actions.

There are two ways to disable a JS function:

  • Set policies to disallow the function
  • Replace it with a dummy function

  • Another option is to set a dummy systemwide printer


Option 1: Security Policies

You can set the Configurable Security Policies by adding the following line to the user.js file (note: Firefox must be fully closed before this file can be modified):

user_pref("capability.policy.default.Window.print", "noAccess");

Alternatively, you could navigate to about:config and add a new string key with the same name and values. Do note that you will not be able to see or remove this key from within the config UI.

If you wish to only block this on specific sites, the following should work (replace the example domains):

user_pref("capability.policy.blockPrinting.Window.print", "noAccess");
user_pref("capability.policy.blockPrinting.sites", "http://example.com http://something.example.com");

The problem with this approach is that it will throw a JS exception, which may interfere with JS execution. The othe rapproach, a dummy JS function, is probably safer.


Option 2: Dummy Function

You can replace the print function with a dummy JS function like so:

window.print = function(){};

Any calls to window.print after this will do nothing. You can execute this on the required page by, e.g., a (Greasemonkey) userscript.


Option 3: Dummy Printer

The third option is to do as you have already done and disable the dialog, and then set the system default printer to one that does nothing. This is not recommended, since it will affect the whole system (though in most other programs you can simply select a different printer, it is inconvenient).

This question addresses creating a dummy printer in Windows.

share|improve this answer
    
Great answer, thanks! Option 1 in particular serves my needs. This way I can block printing from inside of the test classes, meaning not every person running the tests need to set up a dummy printer. –  Magnilex Sep 11 '13 at 11:27

I don't see what this now has to do with Firefox. This is more about the print job.

You can install something a PDF writer as your printer and set it as default... However, you will probably be prompted to create save file names etc which may/may not be desirable.

You may be able to create a 'fake' printer (just install the drivers and software, set it as default so the print job never goes).

Turn the printer off during testing (and remember to clear the queue before turning it back on (this gets my vote but not sure of your exact situation).

There is possibly some 'virtual printer' software already in existence which may suffice for your needs (but recommending any is off topic here so please don't think I'm being unhelpful).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.