Reputation: 1355
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?
Upvotes: 3
Views: 6041
Reputation: 51
the callback apis are called by Chrome when user clicks on pritn/ Ctl+P
onGetPrintersRequested()
this should return the list of printersonGetCapabilityRequested()
in the call back you need to pass the printer capabilities in the CDD formatonPrintRequested()
is invoked when user selects that printer and clicks print from the print dialogueAll 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
Upvotes: 3