10

As, we know in C# windows form application we can print content directly 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.

I am also having the same issue.

Daud
  • 3
  • 2
Mujassir Nasir
  • 1,640
  • 4
  • 31
  • 52
  • 1
    Why do this - and not offer the user the possibility of saving paper/ink? – Ed Heal Dec 24 '14 at 07:46
  • 3
    I want to print tokens and client don't like the print preview again and again. – Mujassir Nasir Dec 24 '14 at 07:47
  • 1
    browser does not let you to do that, but you can force to download it like Click here to download in c# sharp you can directly send parameters to printer but in web , browser will send parameters. – geekido Dec 24 '14 at 08:30
  • @MujassirNasir did you find a solution? I want the same directly print, in my case I have a kiosk like setup -> Scan ticket -> print pdf ? Any ideas, suggestions? – alex Jan 14 '16 at 11:57

5 Answers5

10

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

Community
  • 1
  • 1
Mujassir Nasir
  • 1,640
  • 4
  • 31
  • 52
5

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

Chankey Pathak
  • 21,187
  • 12
  • 85
  • 133
1

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>
Marin Vartan
  • 572
  • 7
  • 16
1

This one worked for me perfectly. If you are using Mozilla Firefox navigate to config files by typing about:config in search bar and hit enter. You will be directed to a page with firefox settings and search for print.always_print_silent. To disable print preview change the boolean value to true and to enable change to true.

It worked for me. In chrome use --kiosk printing.

For more visit https://support.aerocrs.com/hc/en-us/articles/360030321912-Firefox-browser-bypassing-the-print-dialog-box-

Ben Philipp
  • 1,832
  • 1
  • 14
  • 29
0

It is actually possible by following plugins, and then call java script while printing.

1- QZ Tray ( https://qz.io )

2- JS Print Manager ( https://www.neodynamic.com/articles/Print-HTML-from-Javascript-to-client-printer-without-print-dialog-silently/ )