How to skip browser default print preview and print content directly to printer in jquery/javascript?

As, we know in C# windows form application we can print content direclty to print without any preview. I want to print content in jquery/javascript when user click a button, browser does not show any print preview and content printed to printer

Answers:

Answer

Browsers will not allow that to happen. You can use the below plugin to provide beautiful previews.

https://github.com/etimbo/jquery-print-preview-plugin

Demo: http://etimbo.github.io/jquery-print-preview-plugin/example/index.html

Answer

After hours of research I found following solutions to resolve my issue.

Maybe you could setup your printers with Google Clound Print then use the cloud printing API to silently submit jobs to them. It looks like you can specify the printer id when you submit the job. You might need to use something like html2canvas to rasterize the webpage.

Found here Select a printer and silently print

In chrome (v18+) we have the --kiosk --kiosk-printing switches. One can print automatically to default printer without print confirmation.

You can see it from this video http://www.youtube.com/watch?v=D6UHjuvI7IE

Found here Google Chrome Extension: Print the page silently

Answer

it is posible in IE with VBScript script, just put it into your page.

<script type="text/VBScript" 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>

<script type="text/javascript">
   setTimeout(function() { 
        window.print();
        self.close();
   }, 1000);
</script>

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.