doushengyou2617 2015-06-05 05:41
浏览 138

使用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?

  • 写回答

1条回答 默认 最新

  • dongshi9489 2015-06-05 06:16
    关注

    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...).

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题