23

The below snippet working fine, but it opening the dialog box window,

but i dont want to open the print dialog box ,

just print should done without dialog box,

what snippet i should add in the below snippet ,

And also one doubt, i want to take print out in DOT Matrix Printer, the below snippet will work know ?

var prtContent = document.getElementById(strid);
var WinPrint =
window.open('','','left=0,top=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
prtContent.innerHTML=strOldOne;

i developed the billing application ,

If i show the print dialog box, then it consume some seconds to give the print , see i done have more printer, i have only one printer ,that is dot matrix, when ever i give print command , then it should print the BILL without open the print dialog box,

4
  • 2
    How do you expect the user to pick which printer to print to? Commented Nov 27, 2010 at 15:34
  • 2
    @Ignacio Vazquez-Abrams: Most systems have the notion of a "default printer". However, printing from a browser w/o user confirmation sounds like a not-quite-great idea ("but OF COURSE all visitors of our website will want to have a printout of our new ad!" - pop-ups on the screen were bad enough) Commented Nov 27, 2010 at 15:39
  • 1
    Firefox can be configured to print directly without showing the dialog, see forums.mozillazine.org/viewtopic.php?t=48336 Commented Oct 11, 2013 at 12:19
  • in the case of a web application that is hosted on a company intranet you would know the printers and want to be able to have this kind of control. this is the situation i am in right now. Commented Dec 16, 2014 at 20:29

4 Answers 4

9

Download Google Chrome Version 18.xx.xx.xx and you can use flags to turn OFF the printer dialog

--kiosk-noprint

Something of that fashion I can't quite remember off the top of my head but google will help on that. That will allow the dialog to stay out of the way when you select whatever you want to print.

Sign up to request clarification or add additional context in comments.

2 Comments

this is great, thanks. working param is "--kiosk-printing"
How can I use this on Android?
7

This is totally possiable. I work in banking and had a webpage that tellers needed to auto print when a transaction was posted. Since they do transactions all day it would slow them down if they had the dialog box display everytime. This code will select your default printer and print directly to it with no dialog box.

<form>
<input type="button" value="Print Page" onClick="window.print()">
</form>


<script language="VBScript">
// THIS VB SCRIP REMOVES THE PRINT DIALOG BOX AND PRINTS TO YOUR DEFAULT PRINTER
Sub window_onunload()
On Error Resume Next
Set WB = nothing
On Error Goto 0
End Sub

Sub Print()
OLECMDID_PRINT = 6
OLECMDEXECOPT_DONTPROMPTUSER = 2
OLECMDEXECOPT_PROMPTUSER = 1


On Error Resume Next

If DA Then
call WB.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,1)

Else
call WB.IOleCommandTarget.Exec(OLECMDID_PRINT ,OLECMDEXECOPT_DONTPROMPTUSER,"","","")

End If

If Err.Number <> 0 Then
If DA Then 
Alert("Nothing Printed :" & err.number & " : " & err.description)
Else
HandleError()
End if
End If
On Error Goto 0
End Sub

If DA Then
wbvers="8856F961-340A-11D0-A96B-00C04FD705A2"
Else
wbvers="EAB22AC3-30C1-11CF-A7EB-0000C05BAE0B"
End If

document.write "<object ID=""WB"" WIDTH=0 HEIGHT=0 CLASSID=""CLSID:"
document.write wbvers & """> </object>"
</script>

7 Comments

Not sure. I just use IE on a windows PC.
it doesn't work for me at IE 9.0.8112.16421. Does anybody known reasons of this? ActiveX control is allowed..
This is a function I have been looking for. I have tried the code above on a page, and its asking to install an Add-On. This seems to be from microsoft, but, Can anyone tell me: If I install this, will this give OTHER website the power to auto print using the same script? If so, is there a way to limit the Add-On to only one domain?
This doesn't work on IE 9 + either, also I need something like this on chrome. For the same reason this answer describes.
This is an OLD IE ONLY solutuion.
|
-4

It's not possible, and there are a few good reasons for that:

  • the user could want to choose a printer himself
  • the user could want to be able to control when his printer gets activated (imagine nasty auto-selfprinting advertisement popups, ARRGH!)
  • the user could want to specify printer settings (grayscale or color, resolution, size, ...)

7 Comments

It is possible. Please see my comment. And my users are tellers who need to auto print when a transaction is posted. They print to the same printer with the default settings. Nothing ever changes other then the next person that walks up to the tellers window.
-1 This is not the answer. Anybody knows why we need dialog. But there are a lot of scenarios where printing without dialog save time and money. In banking, for example.
i don't buy this as an answer, more of a "you shouldn't do that" comment. I need exactly what the OP is asking for because I am trying to write a program that prints checks, and i cannot allow the user to use the print dialog for this. the accepted answer is close to what I am looking for.
I agree. Many scenarios for restaurants, online shops etc, where this would be very nice.
this is discouraging. Bro, you need to be possitive
|
-4

I think the best alternate will be either Flash or Java....

Flash is very flexible in terms of customizing the OS elements....

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/printing/PrintJob.html

So, user can define Printers through he want to print and you can just pass the name of the printer to the function and that printer will start printing.....

1 Comment

This was probably true in 2013, but Flash is end of life and I can't remember the last time I saw a browser with the Java plugin installed.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.