rendered paste bodyfunction printToFile(window, fileThing, continuation) { var printProgressListener = { onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) { if(aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) continuation(); }, onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress) {}, onLocationChange: function(aWebProgress, aRequest, aLocation) {}, onStatusChange: function(aWebProgress, aRequest, aStatus, aMessage) {}, onSecurityChange: function(aWebProgress, aRequest, state) {} }; var filePath = (fileThing instanceof Ci.nsILocalFile ? fileThing.path : fileThing); var webBrowserPrint = window .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIWebBrowserPrint); var settings = webBrowserPrint.globalPrintSettings; // Empiric evidence ;-) suggests that minimal margins for the // Librie are [top: 0.6, bottom: 0.6, left: 0, right: 0] settings.marginTop = 0.75; settings.marginBottom = 0.75; settings.marginLeft = 0.15; settings.marginRight = 0.15; settings.footerStrCenter = ''; settings.headerStrRight = ''; settings.headerStrLeft = ''; settings.printToFile = true; settings.printSilent = true; settings.toFileName = filePath; settings.printerName = 'PostScript/default'; settings.paperName = 'A4'; settings.showPrintProgress = true; webBrowserPrint.print(settings, printProgressListener);}