How to print, that is, send a page directly to physical print, without displaying the browser dialog before?
I see many examples on the internet but everyone asks for print confirmation.
How to print, that is, send a page directly to physical print, without displaying the browser dialog before?
I see many examples on the internet but everyone asks for print confirmation.
Only with Javascript, is not possible . If it were, it would be a major security breach, imagine you visiting any website and out of nowhere your printer shoots by printing multiple sheets without your permission?
It may be possible through development some extension, but that is the subject of another question.
At the level of knowledge, in Firefox you can make some modifications that allow you to print a document without the confirmation prompt as follows:
about:config
to enter the settings tab (click "I'll be careful, I promise") and continue. print.always_print_silent
and mark it as true
. When restarting the browser, any call via Javascript with code window.print()
will start printing automatically. So even a link like the one below will work:
<a href='javascript:window.print()'>Imprimir essa página</a>
But as you can see anyway, permission is required on the part of the user.
ps: If you did the test above, be sure to re-enter the Firefox preferences tab and change the key print.always_print_silent
to false
(or click on " restore the default ").
I found a "solution" in the OS.en, as I do not have a printer at home, there is no way to test it, but feel free to try and tell us if it worked.
(Free Translation)
I have not found a solution for other browsers. When I posted this question, IE was the highest priority and luckily I found one for it. If you have a solution for other browsers (firefox, safari, opera) please share here. Thank you.
<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 call:
<a href="javascript:window.print();">Print</a>
It will send the printout without the print window being opened.
See the QUESTION page , there are many answers, some really interesting that are worth testing, such as that solution for Chrome , which I do not know if it really works.