How can I print an HTML document with C # or javascript without user confirmation?

I would like to send a print job to the printer without having to click the OK button in the print confirmation dialog box.

Any C # or javascript code will be fine, depending on what works best.

So ... I know that it is possible to print an HTML document, but is it possible to print without clicking the user in order ?

  • The reason I'm asking about this is because the print job prints the document 100 times by dynamically pasting the values โ€‹โ€‹of the forms. (Imagine that you printed a thank you card to 100 people and did not want to change your name 100 times). If the user must confirm the print job for each of these documents, it will take some time to complete one print job. Now imagine that 100 print jobs appeared in one day! This person spends hours to click โ€œgoodโ€ 10,000 times.

Note. . Only one person who will need to use the print form, therefore, if it is a matter of reducing security issues in the browser that will work. I just need a way to allow all 100 prints without confirming each of them (even one confirmation per 100 will be fine, but the document should still change every time).

+3
source share
4 answers

From any major browser - I'm sure you cannot.

You can create a WinForm application with the WebBrowser control built into it and print it without user confirmation (if I remember correctly, there is a method for printing from an object).

+3

, , , , . Firefox ( v. 3.5):

  • : config Firefox
  • , โ†’ boolean โ†’ add "print.always_print_silent" โ†’ "true"
  • Firefox

, window.print() javascript, .

: http://forums.mozillazine.org/viewtopic.php?f=40&t=48336&start=0

+3

Internet Explorer 5.5 , :

function printit(){ 
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'; 
    document.body.insertAdjacentHTML('beforeEnd', WebBrowser); WebBrowser1.ExecWB(6, -1); 
    WebBrowser1.outerHTML = ""; 
}
+1

100 , , .

+1
source

Source: https://habr.com/ru/post/1714925/


All Articles