murray bryant wrote:
I am ( for the first time) trying to use a xpcom interface from my page and have been trying to call the print preview components to view a page.

From xul planet i have learnt that i am required to connect to a service and then call it's instance. However in the XPCOM refence the instance that i want to use nsIWebBrowserPrint does not list a URI and so i am unsure of how to connect to it.

I have tried the following ( with various combinations) and i am aware that the problem is with the @mozilla.org/embedding/browser/nsWebBrowser;1

as this is the wrong component.


netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var abrowser = Components.classes["@mozilla.org/embedding/browser/nsWebBrowser;1"].createInstance(Components.interfaces.nsIWebBrowserPrint);


if (abrowser instanceof Components.interfaces.nsIWebBrowserPrint){

    printWindow = document.getElementByID("print-panel");
    abrowser.printPreview(null,printWindow);

}

Can someone please help me with the correct reference for the component or where i can find a complete list of all of the components

thanks

Murray



looks like you could do this:

  var browserContractID =
    "@mozilla.org/embedding/browser/nsWebBrowser;1";

  var browser =
    Components.classes[browserContractID].createInstance(
      Components.interfaces.nsIInterfaceRequestor);

  var browserPrint = browser.getInterface(
    Components.interfaces.nsIWebBrowserPrint);

  if (browserPrint instanceof Components.interfaces.nsIWebBrowserPrint){
    printWindow = document.getElementByID("print-panel");
    browserPrint.printPreview(null, printWindow);
  }

darin




Reply via email to