Reputation: 1857
Is it possible to print from the Firefox add-on SDK? I have browsed the add-on SDK online docs, but can't seem to find anything about this.
What I would like to do is to retrieve some data from a web page (a PDF file stored in a Javascript variable), and then open the system printer dialog with the file.
Can this be done?
Upvotes: 1
Views: 1373
Reputation: 57681
Add-on SDK doesn't have any built-in functionality for printing. Of course you can do a lot using chrome authority, e.g. given a browser window you can get the nsIWebBrowserPrint
interface for the currently opened window and print it:
var browserPrint = browserWnd.gBrowser
.contentWindow
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebBrowserPrint);
browserPrint.print(null, listener);
But the problem is still that you need to open a web page in browser in order to print it. The browser doesn't open PDF files however, this is done by a plugin - and only the plugin (that the browser has no access to) can print it. You can look in the direction of pdf.js but it is still in early development stages.
page-worker
package looks like an obvious way to load the page into a hidden window so that it can be printed. Only problem - to get to nsIWebBrowserPrint
you would need to access the page's window
object from the add-on (not the content script, it doesn't have the necessary privileges).
Upvotes: 1