简体   繁体   中英

Feasibility of automatically selecting a system printer in client browser with JavaScript

I have been seeking a solution to send a pdf generated with JasperServer to a Brother QL-700 printer upon js page load (from browser), or to at least automatically select and load the label printer's settings so the user has not to define the page settings themselves from within the print dialog.

Having the browser's print dialog display has not been the issue. The settings for the particular printer, especially in IE, tend to eventually be forgotten. So, when normally 3 barcode labels would print just fine on three cut paper strips, there will be four strips due to overflow because of the page margins.

The pdf.js library seems as though it could offer some solution, but I have been unable to uncover much so far from it's well undocumented viewer library.

Is this a reasonable route to take to accomplish this task, or is there a better way?

For security reasons you can't, server side, decide over client resources (such as printer).

It is responsability of your browser or, in turn, any viewer subsidiary called to display some media type (such as pdf) to remember your preferences and maybe store multiple of them and being smart to guess best one according to, for example properties of the document such as page size, etc...

If your browser does it wrong, maybe you should consider to try another one. Or to search for some browser-specific plugin which could threat printers in a smarter way.

BUT, because you are asking for javascript (I suppose to modify web app) I figure out you are in corporate environment. If that is the case, and all clients are in the same LAN or VPN, maybe you can print those labels directly server side.

If there is more than one label printer you may need a few setup to assign the nearest one to each client (by ip, username or whatever you want...).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM