Select a printer and silently print

This answer shows how to enable silent printing in Google Chrome. However, I have two web pages which have to be silently printed using two different printers without further user interaction. Is there a way to select a printer automatically before calling window.print()? I don’t mind writing a Chrome Extension if really necessary.


Maybe you could setup your printers with Google Clound Print then use the cloud printing API to silently submit jobs to them. It looks like you can specify the printer id when you submit the job. You might need to use something like html2canvas to rasterize the webpage.


If you are in an environment that you know, and in wich you have enough privileges (i suppose, since you know the printer you want to use) you can try to change it through the command line. For this, you should call

@RunDLL32.EXE printui.dll,PrintUIEntry /y /n "Printer name"

The printer name has to be the value displayed in the control panel.

For calling command line from javascript, if you have the proper ActiveX controls enabled, you can use:

var run=new ActiveXObject('WSCRIPT.Shell').Run("commands to run");

also, you can try with shell.application ShellExecute

 var objShell = new ActiveXObject("shell.application");
objShell.ShellExecute("cmd.exe", 'RunDLL32.EXE printui.dll,PrintUIEntry /y /n "Printer name"', "C:\\WINDOWS\\system32", "open", 1);

For more information you can go to http://msdn.microsoft.com/en-us/library/windows/desktop/gg537745(v=vs.85).aspx

I havent tested it, so good luck!


I ended up writing a server in F# and communicating with that through a WebSocket.