Here's what I do in PasswordMaker. I populate a new tab with the text to print,
then open the print dialog for the user to preview and/or print.
var printWindow;
function printSettings() {
var wm =
Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser");
printWindow = wm.getMostRecentWindow("navigator:browser");
printWindow.gBrowser.selectedTab = printWindow.gBrowser.addTab("about:blank");
printWindow.gBrowser.selectedBrowser.addEventListener("load",
function() {
var doc = printWindow.gBrowser.contentDocument;
doc.removeChild(doc.getElementsByTagName("html")[0]);
isExporting = false;
var dom = new DOMParser().parseFromString(rdfToHTML(), "text/xml");
doc.appendChild(dom.documentElement);
setTimeout(function() {
// Display the print dialog -- thanks
http://lxr.mozilla.org/aviary101branch/source/toolkit/components/printing/content/printUtils.js
var printSettings, webBrowserPrint;
try {
webBrowserPrint =
printWindow._content.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint);
// Get print settings
var PSSVC =
Components.classes["@mozilla.org/gfx/printsettings-service;1"]
.getService(Components.interfaces.nsIPrintSettingsService);
printSettings = PSSVC.globalPrintSettings;
if (!printSettings.printerName)
printSettings.printerName = PSSVC.defaultPrinterName;
// First get any defaults from the printer
PSSVC.initPrintSettingsFromPrinter(printSettings.printerName,
printSettings);
// now augment them with any values from last time
PSSVC.initPrintSettingsFromPrefs(printSettings, true,
printSettings.kInitSaveAll);
}
catch (e) {
dump(e + "\n");
return;
}
try {
webBrowserPrint.print(printSettings, null);
} catch (e) {
// Pressing cancel is expressed as an NS_ERROR_ABORT return value,
// causing an exception to be thrown which we catch here.
// Unfortunately this will also consume helpful failures, so add a
// dump("print: "+e+"\n"); // if you need to debug
}}, 2000);
}, true);
}
----- Original Message ----
From: Michael Buckley <[EMAIL PROTECTED]>
To: [email protected]
Sent: Friday, July 21, 2006 5:58:06 PM
Subject: [Project_owners] Printing a Variable.
I trying to print the content of a text area I have not got very far in
doing so this is what I have
function printNow() {
var value = theTextArea.value;
var print = Components.classes["@mozilla.org/gfx/printsettings-service;1"]
.getService(Components.interfaces.nsIPrintSettingsService);
}
I can't find out just what I have to do to get the thing to then print it?
Dose any one know?
_________________________________________________________________
Find lost friends & family online! Search for free.
http://ninemsn.com.au/share/redir/adTrack.asp?mode=click&clientID=389&referral=HM_tagline&URL=http://ninemsn.schoolfriends.com.au
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners