本文介绍了Google JavaScript API-Chrome.printerProvider:打印机ID格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用chrome.printerProvider进行打印扩展.谁能给我一个有关PrintInfo id的示例吗?我请求通过网络进行打印,并通过打印机地址设置PrintInfo ID,但是它不起作用.这是我的脚本:

I trying to use chrome.printerProvider to make a printing extension.Can anyone give me an example about PrintInfo id ?I'm request print via network and I setting PrintInfo Id by printer address but it's not working.Here is my script:

chrome.printerProvider.onGetPrintersRequested.addListener(function callback(resultCallback) {
    resultCallback([{
      id: '192.16.1.18', // printer address
      name: 'My Printer',
    }]);
});

or

chrome.printerProvider.onGetPrintersRequested.addListener(function callback(resultCallback) {
    resultCallback([{
      id: 'net://192.16.1.18', // printer address
      name: 'My Printer',
    }]);
});

推荐答案

这应该有效..

chrome.printerProvider.onGetPrintersRequested.addListener(
    function ( resultCallback ) {
        resultCallback( [{
      id: 'net://192.16.1.18', // printer address
      name: 'My Printer',
    }] );
    }
);

这篇关于Google JavaScript API-Chrome.printerProvider:打印机ID格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 16:13