Select a printer and silently print

后端 未结 4 937
既然无缘
既然无缘 2020-12-01 08:31

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 furthe

4条回答
  •  忘掉有多难
    2020-12-01 09:13

    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!

提交回复
热议问题