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.
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.
I have searched for an answer but it looks like there is no way to set a printer programatically. Therefore my probably complicated solution:
Create a command line application which can switch the default printer of the operating system. Maybe an application which is capable of disabling and enabling a printer. If you are on Windows a .NET application could probably do this. If on Linux there should be a command line interface for printer management (I don't know for sure).
Now make for example a PHP, asp.net or ruby etc. page which is able to call the printer enable/disable program.
I hope for you someone comes up with a better solution, but I wanted to at least share my thoughts. Maybe they help you in solving your problem.
©2020 All rights reserved.