I'm coding a web based software. I print barcodes.
There are 2 printers at the PC, so user always has to select barcode printer for printing barcode and laser printer for printing reports.
Is there any way to set a printer for a page. (From browser settings or via javascript)
For example :
www.example.com/barcodeprint.php
----> Barcode printer
www.example.com/reportprint.php
----> Laser printer
Thanks
Open the web page. 2. Press Ctrl + A 3. Right click on the page and left click on “Print” 4.
JavaScript will not allow you to override the default page setup of the client's browser, because the browser protects the hardware and operating system by sandboxing the scripts to avoid anything malicious.
But your issue is similar this question and maybe you could setup your printers with Google Cloud Print then use it's API to do it.
No, unfortunately that’s a machine specific configuration. Even users can have individual configurations of printers.
However there is a little hope. You can execute JS with printing specific event handlers to pop up instructions for the user to select a specific printer. This will help push them to select the correct one.
https://developer.mozilla.org/en-US/docs/Web/Guide/Printing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With