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.
This question is related to
browser
printing
activex
client-side
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.
This should work, I tried it by myself and it worked for me. If you pass True instead of false, the print dialog will appear.
this.print(false);
this.print(false);
I tried this in Chrome, Firefox and IE. It works only in Firefox and IE, it uses the default printer (with default print settings) and only works when I render a PDF (I use Foxit Reader with Safe Reading Mode disabled). Chrome shows the print dialog, also the other browsers when I render an HTML page.
For IE browsers, the "VBScript solution" works.
But as mentioned by @purefusion at Bypass Printdialog in IE9, Use Print() rather than window.print()
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?
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:
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.
Source: Stackoverflow.com