获取 xul 打印中的 Printprogress
我正在做这个 xul 离线应用程序,它有很多打印作业。是否有办法从 xul print 获取进度/监听器,表示它已完成?我已经被这个问题困扰了一段时间了,请分享一些关于如何继续的想法。打印的代码如下。
xul文件
<iframe type="content-primary" flex="1" src="index.html" />
打印函数
function getWebBrowserPrint()
{
return _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint);
}
function printpdf() {
var webBrowserPrint= getWebBrowserPrint();
var gPrintSettings = webBrowserPrint.globalPrintSettings;
gPrintSettings.footerStrLeft = "";
gPrintSettings.footerStrCenter = "";
gPrintSettings.footerStrRight = "";
gPrintSettings.headerStrLeft = "";
gPrintSettings.headerStrCenter = "";
gPrintSettings.headerStrRight = "";
gPrintSettings.printSilent = true;
gPrintSettings.showPrintProgress = true;
gPrintSettings.printerName = "PDF Writer";
webBrowserPrint.print(gPrintSettings, null);
}
I am doing this xul offline application which has lots of print job. Is there anyway to get the progress/listener from xul print, saying it is complete? I am stuck with this for sometime now, please share some ideas on how to proceed. The code for printing is as follows.
xul file
<iframe type="content-primary" flex="1" src="index.html" />
Print Function
function getWebBrowserPrint()
{
return _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint);
}
function printpdf() {
var webBrowserPrint= getWebBrowserPrint();
var gPrintSettings = webBrowserPrint.globalPrintSettings;
gPrintSettings.footerStrLeft = "";
gPrintSettings.footerStrCenter = "";
gPrintSettings.footerStrRight = "";
gPrintSettings.headerStrLeft = "";
gPrintSettings.headerStrCenter = "";
gPrintSettings.headerStrRight = "";
gPrintSettings.printSilent = true;
gPrintSettings.showPrintProgress = true;
gPrintSettings.printerName = "PDF Writer";
webBrowserPrint.print(gPrintSettings, null);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
webBrowserPrint.print
的第二个参数可以是 nsIWebProgressListener 对象。特别是,当打印完成时,您将收到一个onStateChange
回调,其中包含一个包含STATE_STOP
的标志。The second parameter to
webBrowserPrint.print
can be an nsIWebProgressListener object. In particular you'll get anonStateChange
callback with a flag includingSTATE_STOP
when printing has finished.