Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML / Javascript One Click Print (no dialogs)

Tags:

html

printing

Is it possible to have a print option that bypasses the print dialog?

I am working on a closed system and would like to be able to pre-define the print dialog settings; and process the print as soon as I click the button.

From what I am reading, the way to do this varies for each browser. For example, IE would use ActiveX. Chrome / Firefox would require extensions. Based on this, it appears I'll have to write an application in C++ that can handle parameters passed by the browser to auto print with proper formatting (for labels). Then i'll have to rewrite it as an extension for Chrome / Firefox. End result being that users on our closed system will have to download / install these features depending on which browser they use.

I'm hoping there is another way to go about this, but this task most likely violates browser security issues.

like image 761
teynon Avatar asked Feb 09 '12 15:02

teynon


People also ask

How to print in JavaScript without displaying the dialog box?

How to Print in JavaScript Without Displaying the Print Dialog Box Simply assign the desired printer as the default printer in Windows and make sure you’re using the Chrome Engine under the browser settings (the default setting). Then call window.print (); and that’s it! No code modifications to your website are required.

How to print from a website without a print dialog?

I found a awesome plugin by Firefox which solve this issue. try seamless printing plugin of firefox which will print something from a web application without showing a print dialog. After successful installation the printing window will get bypassed when user wants to print anything. This addon is no longer supported.

How to print HTML/CSS card without print dialog?

Run your website and test it. Click on Print Now... to print the HTML/CSS Card without print dialog. You can print it to the Default client printer or you can get a list of the installed printers available at the client machine. Try JSPrintManager Online Demo!

How do I make a button only click once in JavaScript?

There are a number of ways to allow only one-click in Javascript: Disable the button after clicking on it. Use a boolean flag to indicate “clicked”, don’t process again if this flag is true. Remove the on-click attribute from the button after clicking once. Attach an on-click event listener, and detach it after clicking once.


1 Answers

I am writing this answer for firefox browser.

  • Open File > Page Setup

  • Make all the headers and footers blank

  • Set the margins to 0 (zero)

  • In the address bar of Firefox, type about:config

  • Search for print.always_print_silent and double click it

  • Change it from false to true

    • This lets you skip the Print pop up box that comes up, as well as skipping the step where you have to click OK, automatically printing the right sized slip.
  • If print.always_print_silent does not come up

    • Right click on a blank area of the preference window

    • Select new > Boolean

    • Enter "print.always_print_silent" as the name (without quotes)

    • Click OK

    • Select true for the value

  • You may also want to check what is listed for print.print_printer

    • You may have to choose Generic/Text Only (or whatever your receipt printer might be named)
like image 175
Abhijeet Kale Avatar answered Sep 28 '22 16:09

Abhijeet Kale