Print directly to printer using angularjs without showing Window window.open [Resolved]

Posted by Kasani007 under AngularJS 1x on 2/14/2017 | Points: 10 | Views : 11429 | Status : [Member] | Replies : 2
Print directly to printer using angularjs without showing Window window.open ?

I am trying to print direclty to the printer using below code

 popupWin.document.open();
popupWin.document.write('<html><head><link rel="stylesheet" type="text/css" href="style.css" /></head><body onload="window.print()">' + printContents + '</body></html>');



It is Showing Window and again asking for print option again..

I want to give print directly to the default selected printer..

how can i achieve this using angularjs

Thanks In Advance




Responses

Posted by: Rajnilari2015 on: 2/14/2017 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
@Kasani007 Sir,
Yes it is possible. The below code will do so (obtained from:http://stackoverflow.com/questions/4292373/javascript-print-without-print-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>


Thanks .

--
Thanks & Regards,
RNA Team

Kasani007, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kasani007 on: 2/15/2017 [Member] Starter | Points: 25

Up
0
Down
Hi Rajnilari2015,
i don't need landscape,
i don't want to show the window.print().
i want print ,when i click on button in HTML page, it has to print directly to the default printer without showing printpreview dialog or window and ask again for print .
I need direct print from the print, because i have to change the status in button click event as well as print to printer direcly

How can i achieve that...please help me

Kasani007, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response