Print directly from browser without print popup window
Solution 1
I couldn't find solution for other browsers. When I posted this question, IE was on the higher priority and gladly I found one for it. If you have a solution for other browsers (firefox, safari, opera) please do share here. Thanks.
VBSCRIPT is much more convenient than creating an ActiveX on VB6 or C#/VB.NET:
<script language='VBScript'>
Sub Print()
OLECMDID_PRINT = 6
OLECMDEXECOPT_DONTPROMPTUSER = 2
OLECMDEXECOPT_PROMPTUSER = 1
call WB.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,1)
End Sub
document.write "<object ID='WB' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object>"
</script>
Now, calling:
<a href="javascript:window.print();">Print</a>
will send print without popup print window.
Solution 2
AttendStar created a free add-on that suppresses the print dialog box and removes all headers and footers for most versions of Firefox.
https://addons.mozilla.org/en-US/firefox/addon/attendprint/
With that feature on you can use $('img').jqprint(); and jqprint for jquery will only print that image automatically called from your web application.
Solution 3
IE9 no longer supports triggering the Print() VBScript by calling window.print() like IE7 and IE8 do, and thus window.print() will now always trigger the print dialog in IE9.
The fix is pretty simple. You just need to call Print() itself, instead of window.print() in the onclick event.
I've described the fix in more detail in an answer to another question, with a working code example sporting slightly updated HTML syntax (as much as possible while still tested as working code).
You can find that sample code here:
Solution 4
I don't believe this is possible. The dialog box that gets displayed allows the user to select a printer to print to. So, let's say it would be possible for your application to just click and print, and a user clicks your print button, but has two printers connected to the computer. Or, more likely, that user is working in an office building with 25 printers. Without that dialog box, how would the computer know to which printer to print?
Related videos on Youtube
Comments
-
Ramiz Uddin about 4 years
As it said in the subject I've to create a feature for a web-based application that will allow users to send print directly without prompting any dialog boxe just make the print i.e click and print, simple! but not for me :(.
Please, suggest what would be the best option and how should I write it up (technology).
Suggest please!
Thanks.
EDIT: The print should be send on the user's default printer.
-
Ramiz Uddin almost 15 yearsHow about ActiveX control for IE that will send a print on the user's default printer. This looks a pretty doable. But, invest hours of effort to create such an activeX is not justified to provide feature for only IE users.
-
Ramiz Uddin almost 15 yearsZachary, the above script send a print command on a default printer machine without showing any popup window. But this is for IE only. I hope this will answer the doubts we had :)
-
Zachary Murray almost 15 yearsOh wow, I didn't even think to use VBScript. Great going, Ramiz. If you're only using IE, then you are completely set :D
-
Ramiz Uddin almost 15 yearsThanks. The search is still on as there are long list of browsers and this need to be done in all. But, IE was on a higher priority so a bit relaxed.
-
Jordão almost 14 yearsI tried to implement the exact same code in Javascript and it didn't work. Only in VBScript. Why does it work in VBScript but not in Javascript?
-
Ramiz Uddin over 13 years@Jordao I think the above configuration variables are only members of vbscript. Here, in the above script what we mainly doing is resetting up configuration variables. This is just an instinct thought of your question.
-
Jordão over 13 yearsthe variables you refer to are just constants. They should work the same in Javascript.
-
Admin about 9 yearsIs there a way to possibly print a page in an iframe with this method?
-
Eric Wiener over 7 yearsDoes this still work? I tried it and I received a prompt.
-
vasuy19 over 7 yearsI verified in IE11, getting print dialogue.
-
Srinivasan almost 7 yearsThis works perfect in IE. but in chrome again it shows print dialog box
-
Naz141 almost 6 yearsno luck on this script, I tried on IE 11, The print dialog prompts
-
Marinpietri almost 4 yearsYou can do using a extension for chrome,: chrome.google.com/webstore/detail/chrome-direct-print/…