3

I find the developer link; https://developer.chrome.com/extensions/printerProvider

But, couldn't understand how to use it.

I've tried to print the current page without showing a print popup.

To be able to achieve it, I look printer provider, but was not successful.

manifest.json:

{
  "name": "Print this page",
  "description": "Adds a print button to the browser.",
  "version": "1.1",
  "background": {
    "scripts": ["background.js"]
  },
  "permissions": [
    "tabs", "http://*/*", "https://*/*", "printerProvider"
  ],


  "browser_action": {
    "default_icon": "icon.png"
  },
  "manifest_version": 2
}

background.js

chrome.printerProvider.onGetCapabilityRequested.addListener(function callback) {
    alert(callback);
});


chrome.printerProvider.onGetPrintersRequested.addListener(function callback){
    console.log(callback);
});

But, these callbacks return nothing.

How can I use/trigger these events?

Makyen
  • 31,849
  • 12
  • 86
  • 121
mmu36478
  • 1,295
  • 4
  • 19
  • 40
  • 1
    FYI: Asking for examples, etc. is considered a request for an off-site resource. Such requests are off-topic. I have removed the portion of your question which was requesting such examples. – Makyen Apr 18 '17 at 16:09
  • Possible duplicate of [Chrome extensions for silent print?](http://stackoverflow.com/questions/31888183/chrome-extensions-for-silent-print) – Daniel Herr Apr 18 '17 at 16:22

1 Answers1

3

the callback apis are called by Chrome when user clicks on pritn/ Ctl+P

  • onGetPrintersRequested() this should return the list of printers
  • onGetCapabilityRequested() in the call back you need to pass the printer capabilities in the CDD format
  • onPrintRequested() is invoked when user selects that printer and clicks print from the print dialogue

All these callback methods needs to be implemented in your background.js

And The call back functions you have provided are not correct. Refer to the documentations for the signature of the callbacks

gakubhat
  • 51
  • 6