Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print directly from browser without print popup window [duplicate]

Tags:

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.

like image 720
Ramiz Uddin Avatar asked Jul 08 '09 08:07

Ramiz Uddin


People also ask

How do I print directly from the browser without popping up a pop up window?

The fix is pretty simple. You just need to call Print() itself, instead of window. print() in the onclick event.


1 Answers

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.

like image 199
Ramiz Uddin Avatar answered Oct 27 '22 01:10

Ramiz Uddin