[英]Print preview xulrunner
So I'm having this problem with opening print preview in xulrunner. 所以我在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:
这是PrintUtils.js中创建工具栏的代码:
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. 我提供了navToolbox,那是插入工具栏但未显示的地方。 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
. 因此,当enternig printPreview时,您必须传递具有5个功能的对象:
getSourceBrowser
, getPrintPreviewBrowser
, getNavToolbox
, onEnter
和onExit
。
With getNavToolbox
you pass the reference to toolbar (placeholder) where you want to place standard navigation toolbar (with print button, zoom, and others). 使用
getNavToolbox
您可以将引用传递到要放置标准导航工具栏(带有打印按钮,缩放和其他按钮)的工具栏(占位符)。
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. 我在onEnter函数中执行此操作。
But i also had problem with the enterPrintPreview
function from PrintUtils.js
. 但是我也对
enterPrintPreview
函数有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: 我通过获取对我在
getNavToolbox
函数中传递的工具栏的引用,然后对他调用updateToolbar
解决此问题,如下所示:
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. 现在一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.