Javascript – How to print an HTML document from C# or javascript without user confirmation

cconfirmationhtmljavascriptprinting

I would like to send a print job to the printer without the user having to click "okay" on the print confirmation dialog window.

Either C# code-behind or javascript would be fine, whichever works better.

So… I know it it possible to print an HTML document, but is it possible to print without the user clicking okay?

  • The reason I ask this is because the print job prints off a document 100 times, dynamically inserting form values. (Imagine you were printing off a thank you card to 100 people, and didn't want to change the name yourself 100 times). If the user has to confirm the print job for each of these document, it's going to take a while to finish just one print job. Now imagine if 100 print jobs came in in one day! That's one person spending hours just to click "okay" 10000 times.

Note: It's only one person who's going to need to use the printing form, so if it's a matter of lowering security issues in the browser that would work. I just need a way to allow all 100 prints to go through without confirmation of each one (even just 1 confirmation per 100 would be fine, but the document still has to change each time).

Best Answer

From any major browser -- I'm pretty sure you can't.

You could create a WinForm app that has a WebBrowser control embedded in it and print from there without user confirmation (if I remember correctly, there is a Print method off the object).