How to bypass web browser print preview and any print dialog

SPL1991 1 Reputation point
2021-04-21T12:30:26.527+00:00

Hello, I am currently designing and developing a project in Visual Studio using Asp.net and javascript.

The project has the need to print, but it would be ideal to print without any print dialog or print preview.

I am looking for help to print from Microsoft Edge or Google Chrome without the print preview or system dialog.

I am willing to include it as part of the project development or by setting it up at each individual computer that needs a setting applied.

Thank you very much.

Microsoft Edge Microsoft Edge development
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Taylor 60,161 Reputation points
    2021-04-21T14:46:09.44+00:00

    For an arbitrary browser you can't. It is a security risk, theoretically. JS only supports a single print function and that always pops up the print dialog so the user has control over whether something is printed or not. This is necessary because only the user knows which printer/settings to use (in many cases) and it prevents a webpage from spamming the printer which some places charge money to use (such as for grants).

    Having said that if you have a controlled environment then there are some things that you may be able to do. Firstly ensure that Windows has a default printer configured. Some browsers allow silent printing with a command line flag as discussed here.


  2. MD.FARMAN ALI (Barcode technology) 1 Reputation point
    2022-08-11T10:24:31.173+00:00

    Silent mode print method.

    1. Set up the receipt printer as your default printer in the Devices/Printers screen.
    2. In Firefox, type in “about:config” and hit Enter.
    3. A dialogue box will appear, press “I'll be careful, I promise.”
    4. Right click, select New | Boolean.
    5. Type in: print.always_print_silent.
    6. Select True, then OK.

    for more information click to this link https://www.farmanitfirm.com/

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.