question

SPL1991-2066 avatar image
0 Votes"
SPL1991-2066 asked MDFARMANALIBarcodetechnology-1085 answered

How to bypass web browser print preview and any print dialog

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.

ms-edge
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@SPL1991-2066,
I agree with the suggestions provided by the other community members regarding the security-related issues with the silent print from your web application.
If you have tried some code and if you are getting any error then we can help to check that code and try to provide some suggestions. I search but did not get any working code example to print silently using the simple JS code.
Even if you somehow manage to do it, you need to think about many situations that might break your code.
For example, what if the client machine does not have a printer but the user tries to print using your web app.

0 Votes 0 ·
cooldadtx avatar image
0 Votes"
cooldadtx answered cheong00 commented

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.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Or in the case of "controlled environment" and especially to print files like PDF, it's better to print on the server with server side code. You just need to expose a user setting to remember the selected printer so you know the networked printer you need to print to, then it's trivial to select that printer and print it without any dialog.

This way you don't even need to care what browser the user is using.

0 Votes 0 ·
MDFARMANALIBarcodetechnology-1085 avatar image
0 Votes"
MDFARMANALIBarcodetechnology-1085 answered

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/





5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.