Reputation: 1053
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
Upvotes: 7
Views: 4565
Reputation: 1053
best way is using js print setup extension on firefox. But the extension dos not support over firefox 56. So you have to donwload max firefox 56 version, disconnect internet (automatically updates to firefox 58), setup firefox, disable auto update then re-connect internet. By this way you can use a specific printer without select printer dialog.
Thanks for other replies.
Upvotes: 1
Reputation: 9927
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.
Upvotes: 6
Reputation: 2143
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
Upvotes: 1