So I'm having this problem with opening print preview in xulrunner. I open print preview but i can't get the navigation toolbar. This is the code from PrintUtils.js where the toolbar is created:
var XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
printPreviewTB = document.createElementNS(XUL_NS, "toolbar");
printPreviewTB.setAttribute("PrintPreview", true);
printPreviewTB.id = "print-preview-toolbar";
printPreviewTB.className = "toolbar-primary";
And later it does this:
var navToolbox = this._callback.getNavToolb
navToolbox.parentNode.insertBefore(printPreviewTB, browser);
I'm providing the navToolbox, that's the place where the toolbar is inserted but it doesn't show. As I said, print preview opens perfectly, pages formatted and everything but without toolbar.
Anyone have any idea why?
Ok, i found soulution, if anyone is interested.
So when enternig printPreview you have to pass an object with 5 functions:
getSourceBrowser
, getPrintPreviewBrowser
, getNavToolbox
, onEnter
and onExit
.
With getNavToolbox
you pass the reference to toolbar (placeholder) where you want to place standard navigation toolbar (with print button, zoom, and others).
I have done all that but you have to bind to that toolbar, like this :
toolbar.style.MozBinding = url('chrome://global/content/printPreviewBindings.xml#printpreviewtoolbar')";
I'm doing that in the onEnter function.
But i also had problem with the enterPrintPreview
function from PrintUtils.js
.
In this part of code:
var printPreviewTB = document.getElementById("print-preview-toolbar");
if (printPreviewTB) {
printPreviewTB.updateToolbar();
tmptoolbar.updateToolbar();
var browser = this._callback.getPrintPreviewBrowser();
browser.collapsed = false;
browser.contentWindow.focus();
return;
}
printPreviewTB.updateToolbar();
throws error.
I fixed this by getting the reference to the toolbar that i passed in getNavToolbox
function and then calling updateToolbar
on him, like this:
var printPreviewTB = document.getElementById("print-preview-toolbar");
if (printPreviewTB) {
var tmptoolbar = this._callback.getNavToolbox();
tmptoolbar.updateToolbar();
var browser = this._callback.getPrintPreviewBrowser();
browser.collapsed = false;
browser.contentWindow.focus();
return;
}
And now everything works fine.