Darin Fisher wrote:
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

Thanks for your answer

Unfortunately i am still getting an error:


Error: uncaught exception: [Exception... "Component returned failure code: 0x80004002 (NS_NOINTERFACE) [nsIInterfaceRequestor.getInterface]" nsresult: "0x80004002 (NS_NOINTERFACE)" location: "JS frame :: http://skm-bsd.skm.harmonygold.com.au/xul/reports/reportsManager.xul?src=p_induction_expiry.php :: ppv :: line 26" data: no]


Do you have any idea why this is not working.

Also can you recomend any books or websites where i can get some more information on these interfaces

Thankyou

Murray




Reply via email to